Running Tomcat 9 with SpringBoot-App as a service with Ubuntu 18.04

Mike

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

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.

edited at
0

Comments

0 comments
Login to comment

Related

Spring boot web app not running on tomcat 9

Java 9 REPL for running app

Debian execute springboot app as service: service not found

Passing JVM arguments to Tomcat when running as a service?

Passing JVM arguments to Tomcat when running as a service?

Unable to use JConsole with Tomcat running as windows service

NoClassDefFoundError when running app with external lib with Tomcat

SpringBoot app. running Tests

Kill tomcat service running on any port, Windows

Classpath problem with Tomcat 9 and web app subdirectory

How do you install CGAL with QT5 on Ubuntu 18:04?

Ubuntu running Multiple .service files

webapps folder in Tomcat9 - Ubuntu

Since this morning the network is unreachable Ubuntu 18:04

ubuntu-minimal 18:04 how to login via ssh?

ClassNotFoundException while running web service with tomcat 7?

Running OpenResty as a service on Ubuntu 14.04

Running a node app in ubuntu

Running an app with multicores on ubuntu

Error while running Sinatra app on Cloud 9

How To Restart Sudo Service in Ubuntu 18+

tomcat 9 service opens handle(?) on tomcat 9 command line instance

How to check if app is running on Tomcat 7 embedded?

Cordova plugin for running app in background in Android 9

Angular 9 PWA: Service Worker / Manifest scope issues when running app in subdirectory and service worker hosted in a different subdirectory

Ubuntu tomcat9 Jenkins setup issue

Convert Date and Time in required format "Jun 9 18:04:42:"

Apache Tomcat 9 not running on Eclipse IDE

Running a simple WebJob on an app service