The tomcat9.service doesn't use JAVA_HOME defined in /etc/default/tomcat9

Bug #1880694 reported by Josef Cacek
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
tomcat9 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

When I define JAVA_HOME in /etc/default/tomcat9, it's not used by the tomcat9 after the service restart.

I have 2 JDKs installed
openjdk-11-jdk
openjdk-14-jdk

The /etc/default/tomcat9 contains:
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
JAVA_OPTS="-Djava.awt.headless=true -Dspring.profiles.active=production"

After the tomcat9 service restart, the Java version used is still 14:
java.specification.version=14

== Workaround
It started to work with Java 11 when I added following line to the service file (/usr/lib/systemd/system/tomcat9.service):
EnvironmentFile=/etc/default/tomcat9

It was followed by:
sudo systemctl daemon-reload
sudo systemctl restart tomcat9.service

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: tomcat9 9.0.31-1 [modified: lib/systemd/system/tomcat9.service]
ProcVersionSignature: Ubuntu 5.4.0-31.35-generic 5.4.34
Uname: Linux 5.4.0-31-generic x86_64
ApportVersion: 2.20.11-0ubuntu27
Architecture: amd64
CasperMD5CheckResult: skip
CurrentDesktop: MATE
Date: Tue May 26 14:22:05 2020
InstallationDate: Installed on 2020-04-30 (25 days ago)
InstallationMedia: Ubuntu-MATE 20.04 LTS "Focal Fossa" - Release amd64 (20200423)
PackageArchitecture: all
SourcePackage: tomcat9
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.default.apport: [modified]
modified.conffile..etc.tomcat9.policy.d.01system.policy: [inaccessible: [Errno 13] Permission denied: '/etc/tomcat9/policy.d/01system.policy']
modified.conffile..etc.tomcat9.policy.d.02debian.policy: [inaccessible: [Errno 13] Permission denied: '/etc/tomcat9/policy.d/02debian.policy']
modified.conffile..etc.tomcat9.policy.d.03catalina.policy: [inaccessible: [Errno 13] Permission denied: '/etc/tomcat9/policy.d/03catalina.policy']
modified.conffile..etc.tomcat9.policy.d.04webapps.policy: [inaccessible: [Errno 13] Permission denied: '/etc/tomcat9/policy.d/04webapps.policy']
modified.conffile..etc.tomcat9.policy.d.50local.policy: [inaccessible: [Errno 13] Permission denied: '/etc/tomcat9/policy.d/50local.policy']
mtime.conffile..etc.default.apport: 2020-05-02T16:24:39.955346

Revision history for this message
Josef Cacek (josef-cacek) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in tomcat9 (Ubuntu):
status: New → Confirmed
Revision history for this message
Te Plyuska (teplyuska) wrote :

Hello

While "/usr/libexec/tomcat9/tomcat-start.sh" sources "/etc/default/tomcat9" the variable is not available from "catalina.sh".

"/usr/libexec/tomcat9/tomcat-start.sh" specifically exports JAVA_OPTS which is available from "catalina.sh"

Which is the best place to configure these things?
 - /etc/default/tomcat9
 - /usr/lib/systemd/system/tomcat9.service
 - $CATALINA_BASE/bin/setenv.sh (as suggested by catalina.sh)

For my application i also need to add additional ReadWritePaths in "/lib/systemd/system/tomcat9.service"

For me it makes sense to ignore "/etc/default/tomcat9" because other application specific configurations has to be done in the tomcat9.service anyway? Why not do them all here then?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.