actually I'm not able to run a Tomcat9-WebApp properly. I'd be thankful for any help pointing me in the right direction.
Setup:
OS: Ubuntu 18.04
App-Server: Tomcat 9.0.12 (also tested with 8.5.34)
Web-App: SpringBoot 1.5.7
JDK: 1.8.0_181
Script-Command for the startup: $CATALINA_HOME/bin/startup.sh
setenv.sh:
JRE_HOME=path/to/jdk
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
LOGGING_CONFIG="-Dlog4j.configurationFile=$CATALINA_BASE/conf/log4j2.xml"
LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/lib/log4j-jul-2.11.1.jar:$CATALINA_HOME/lib/log4j-core-2.11.1.jar:$CATALINA_HOME/lib/log4j-api-2.11.1.jar:$CATALINA_HOME/lib/log4j-slf4j-impl-2.11.1.jar
If I'm running the script as a root-user it works properly and the tomcat is fully functional.
But if I'm running the same script as a service it hangs during deployment of the WAR. CPU-usage raises constantly to 100%
systemctl start tomcat
Trace-Logs make me thinking, Tomcat is scanning each directory of the filesystem for Configuration-classes (e.g.: /sys/devices/pci0000:00/0000:00:18.6/subsystem/)
o.a.c.s.ContextConfig: Scanning directory for class files with annotations [/sys/devices/pci0000:00/0000:00:18.6/subsystem ....
The Logfiles itselfs are bigger than 200MB. The upper line is just a sample.
As said before, any help would be greatly appreciated.
@Edit
Progress: I reseted the tomcat-logging to default. As soon as this is done. Everything works fine.
Best wishes
Mike
Finally I got it working:
The issue depends on the export CLASSPATH-Command:
I don't know why, but there must not be the extension of the CLASSPATH.
Solution: Replace
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/lib/log4j-jul-2.11.1.jar:$CATALINA_HOME/lib/log4j-core-2.11.1.jar:$CATALINA_HOME/lib/log4j-api-2.11.1.jar:$CATALINA_HOME/lib/log4j-slf4j-impl-2.11.1.jar
with
export CLASSPATH=$CATALINA_HOME/lib/log4j-jul-2.11.1.jar:$CATALINA_HOME/lib/log4j-core-2.11.1.jar:$CATALINA_HOME/lib/log4j-api-2.11.1.jar:$CATALINA_HOME/lib/log4j-slf4j-impl-2.11.1.jar
and the service is starting properly.
If anyone could give an explanation to this behavior. Me and I'll bet others too would love get deeper into this.
@Edit
Well I have a possible explanation for this behavior. As $CLASSPATH is not defined during startup the result is possible "". So the starting of this line seems to be ":/another/path..." It could interepreted like "/:/another/path...". The result is, that "/" is member of the classpath. That could force spring to scan the whole filesystem.
Important: This is only a guess and it is not verified.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments