After installation, tomcat-8.5.57 fails to start with the following exception: /usr/share/tomcat-8.5/bin/catalina.sh run Using CATALINA_BASE: /usr/share/tomcat-8.5 Using CATALINA_HOME: /usr/share/tomcat-8.5 Using CATALINA_TMPDIR: /usr/share/tomcat-8.5/temp Using JRE_HOME: /home/robert/.gentoo/java-config-2/current-user-vm Using CLASSPATH: //usr/share/tomcat-8.5/bin/bootstrap.jar://usr/share/tomcat-8.5/bin/tomcat-juli.jar://usr/share/tomcat-8.5/lib/annotations-api.jar://usr/share/tomcat-8.5/lib/catalina-ant.jar://usr/share/tomcat-8.5/lib/catalina-ha.jar://usr/share/tomcat-8.5/lib/catalina-storeconfig.jar://usr/share/tomcat-8.5/lib/catalina-tribes.jar://usr/share/tomcat-8.5/lib/catalina.jar://usr/share/tomcat-8.5/lib/jasper-el.jar://usr/share/tomcat-8.5/lib/jasper.jar://usr/share/tomcat-8.5/lib/jaspic-api.jar://usr/share/tomcat-8.5/lib/tomcat-api.jar://usr/share/tomcat-8.5/lib/tomcat-coyote.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-de.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-es.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-fr.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-ja.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-ko.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-ru.jar://usr/share/tomcat-8.5/lib/tomcat-i18n-zh-CN.jar://usr/share/tomcat-8.5/lib/tomcat-jni.jar://usr/share/tomcat-8.5/lib/tomcat-util-scan.jar://usr/share/tomcat-8.5/lib/tomcat-util.jar://usr/share/tomcat-8.5/lib/tomcat-websocket.jar://usr/share/tomcat-8.5/lib/websocket-api.jar java.util.logging.ErrorManager: 4: Unable to create [/usr/share/tomcat-8.5/logs] java.util.logging.ErrorManager: 4: Unable to create [/usr/share/tomcat-8.5/logs] java.util.logging.ErrorManager: 4: Unable to create [/usr/share/tomcat-8.5/logs] java.util.logging.ErrorManager: 4: Unable to create [/usr/share/tomcat-8.5/logs] 31-Jul-2020 14:48:33.321 WARNING [main] org.apache.catalina.startup.ClassLoaderFactory.validateFile Problem with directory [/etc/tomcat-8.5/${gentoo.classpath}], exists: [false], isDirectory: [false], canRead: [false] 31-Jul-2020 14:48:33.714 SEVERE [main] org.apache.tomcat.util.digester.Digester.startElement Begin event threw error java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) Looking at the CLASSPATH, this is merely expectable, as the JAR files of dev-java/tomcat-servlet-api (residing in /usr/share/tomcat-servlet-api-3.1/lib) are missing in the classpath. The classpath is read from /usr/share/tomcat-8.5/package.env, which also lacks the tomcat-servlet-api JAR files. After adding them to the CLASSPATH variable in /usr/share/tomcat-8.5/package.env, tomcat starts fine.
See also the following discussion: https://forums.gentoo.org/viewtopic-p-8486250.html
package.env is correct, it also contains DEPEND="eclipse-ecj-4.5:tomcat-servlet-api-3.1" which pulls in the jars. the problem is that you are attempting to run tomcat using startup.sh which is not supported on gentoo. the correct way to set up a tomcat instance and run it is to use /usr/share/tomcat-8.5/gentoo/tomcat-instance-manager.bash and then use the created init.d script. here is the output of the instance manager help: # /usr/share/tomcat-8.5/gentoo/tomcat-instance-manager.bash No action specified! Usage: /usr/share/tomcat-8.5/gentoo/tomcat-instance-manager.bash <--create|--remove|--help> [--suffix s][--user u][--group g] Options: --help: show this text. --create: create a new instance --remove: remove an existing instance. --suffix SUFFIX: a suffix for this instance. the suffix may not collide with an already existing instance, defaults to empty. --user USER: the user for which to configure this instance for. The user needs to exist already. defaults to tomcat. --group GROUP: the group for which to configure this instance for. The group needs to exist already. defaults to tomcat. Examples: /usr/share/tomcat-8.5/gentoo/tomcat-instance-manager.bash --create --suffix testing --user tacmot --group tacmot /usr/share/tomcat-8.5/gentoo/tomcat-instance-manager.bash --remove --suffix testing
Please consider some IDEs depend on catalina.sh to run Tomcat for local development. That was why I originally stumbled across this issue. I acknowledge package.env is correct, but catalina.sh doesn't read the whole classpath from it (missing the dependencies). My proposed patch just fixes that. I don't see anything against fixing catalina.sh, even though it's not officially supported. What do you think?
ok, this is a valid reason.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a28532a65d5975ac732ec7e8fa107a297bfb677d commit a28532a65d5975ac732ec7e8fa107a297bfb677d Author: Robert Siebeck <gentoo.2019@r123.de> AuthorDate: 2020-07-31 13:06:39 +0000 Commit: Miroslav Šulc <fordfrog@gentoo.org> CommitDate: 2020-08-07 07:51:01 +0000 www-server/tomcat: fix missing dependencies in classpath in catalina.sh Closes: https://bugs.gentoo.org/734948 Signed-off-by: Robert Siebeck <gentoo.2019@r123.de> Closes: https://github.com/gentoo/gentoo/pull/16916 Signed-off-by: Miroslav Šulc <fordfrog@gentoo.org> www-servers/tomcat/tomcat-7.0.105-r1.ebuild | 146 ++++++++++++++++++++++ www-servers/tomcat/tomcat-8.5.57-r1.ebuild | 163 ++++++++++++++++++++++++ www-servers/tomcat/tomcat-9.0.37-r1.ebuild | 187 ++++++++++++++++++++++++++++ 3 files changed, 496 insertions(+)