Your message dated Tue, 24 Nov 2020 07:33:34 +0000
with message-id <[email protected]>
and subject line Bug#966338: fixed in tomcat9 9.0.40-1
has caused the Debian Bug report #966338,
regarding tomcat9: overrriding JAVA_HOME in /e/d/tomcat9 has changed
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
966338: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=966338
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: tomcat9
Version: 9.0.31-1~deb10u2
Severity: normal
Tags: patch

I'm reporting a change in behaviour from tomcat8 and I'm not sure what the
correct fix is. While I'm reporting against the buster version, the issue
still seems to exist in current git (1ac6d044 Update changelog).

The gist is trying to override JAVA_HOME in the /etc/defaults/tomcat9 file
now _requires_ an export statement. This was not the case for tomcat8.

Gory details:

I found this on a machine upgraded from stretch to buster.
The old java version was the default and tomcat8 was still running:

% update-alternatives --display java
java - manual mode
  link best version is /usr/lib/jvm/java-11-openjdk-amd64/bin/java
  link currently points to /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
  link java is /usr/bin/java
  slave java.1.gz is /usr/share/man/man1/java.1.gz
/usr/lib/jvm/java-11-openjdk-amd64/bin/java - priority 1111
  slave java.1.gz: /usr/lib/jvm/java-11-openjdk-amd64/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1069
  slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz


When I tried to start tomcat9 under java 11,
I did made the usual change in /etc/default/tomcat9

  #JAVA_HOME=/usr/lib/jvm/java-8-openjdk
 +JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

But when tomcat9 starts, it reports it is running under java 8
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server 
version name:   Apache Tomcat/9.0.31 (Debian)
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server 
built:          Jul 15 2020 11:43:33 UTC
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server 
version number: 9.0.31.0
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:     
          Linux
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:  
          4.19.0-9-amd64
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log 
Architecture:          amd64
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:   
          /usr/lib/jvm/java-8-openjdk-amd64/jre
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 
          1.8.0_252-8u252-b09-1~deb9u1-b09
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:  
          Oracle Corporation
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log 
CATALINA_BASE:         /var/lib/tomcat9
 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log 
CATALINA_HOME:         /usr/share/tomcat9


This seems to be because there is no export of JAVA_HOME when it is overridden,
i.e. this configuration in /etc/default/tomcat9 works correctly:

  #JAVA_HOME=/usr/lib/jvm/java-8-openjdk
 +JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
 +export JAVA_HOME

The 'export' was not necessary in tomcat8 because the init script takes
care of it

     81 # Look for the right JVM to use
     82 for jdir in $JDK_DIRS; do
     83     if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
     84         JAVA_HOME="$jdir"
     85     fi
     86 done
     87 export JAVA_HOME

Where the startup sequence loses track of a JAVA_HOME override is when
  /usr/libexec/tomcat9/tomcat-start.sh
execs into
  "/usr/share/tomcat9/bin/catalina.sh run"
and that script sources
   /usr/share/tomcat9/bin/setclasspath.sh

In that script this test fails and JAVA_HOME is set to /usr
     24 # Make sure prerequisite environment variables are set
     25 if [ -z "$JAVA_HOME" ] && [ -z "$JRE_HOME" ]; then
     26   if $darwin; then
...
     34   else
     35     JAVA_PATH=`which java 2>/dev/null`
     36     if [ "x$JAVA_PATH" != "x" ]; then
     37       JAVA_PATH=`dirname "$JAVA_PATH" 2>/dev/null`
     38       JRE_HOME=`dirname "$JAVA_PATH" 2>/dev/null`
     39     fi


The squence of events leading up to this is
systemd calls
  /usr/libexec/tomcat9/tomcat-start.sh
which sources
  /etc/default/tomcat9
and then sources
  /usr/libexec/tomcat9/tomcat-locate-java.sh

This script does the same job as the init script code above,
but the important difference is that it only exports JAVA_HOME
if it updates it; if JAVA_HOME is already set then the script
does not export it.

Before, that hunk of code exported JAVA_HOME unconditionally.

Then we exec into catalina.sh and the not-exported JAVA_HOME override is lost.


Possible fixes:

 * tweak the example override in /etc/default/tomcat9
   - #JAVA_HOME=/usr/lib/jvm/java-8-openjdk
   + #JAVA_HOME=/usr/lib/jvm/java-8-openjdk; export JAVA_HOME

 * unconditionally export JAVA_HOME

--- tomcat-locate-java.sh       2020-07-27 16:13:45.903064630 +1000
+++ tomcat-locate-java.sh.new   2020-07-27 16:14:09.283692229 +1000
@@ -40,10 +40,11 @@
             JAVA_HOME="$jdir"
         fi
     done
-    export JAVA_HOME
 fi

 if [ -z "$JAVA_HOME" ]; then
     echo "<2>No JDK or JRE found - Please set the JAVA_HOME variable or 
install the default-jdk package"
     exit 1
 fi
+
+export JAVA_HOME


Kind regards
Vince

-- System Information:
Debian Release: 10.4
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-debug')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-9-amd64 (SMP w/28 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_AU:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages tomcat9 depends on:
ii  lsb-base        10.2019051400
ii  systemd         241-7~deb10u4
ii  tomcat9-common  9.0.31-1~deb10u2
ii  ucf             3.0038+nmu1

Versions of packages tomcat9 recommends:
pn  libtcnative-1  <none>

Versions of packages tomcat9 suggests:
pn  tomcat9-admin     <none>
pn  tomcat9-docs      <none>
pn  tomcat9-examples  <none>
pn  tomcat9-user      <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
Source: tomcat9
Source-Version: 9.0.40-1
Done: Emmanuel Bourg <[email protected]>

We believe that the bug you reported is fixed in the latest version of
tomcat9, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Emmanuel Bourg <[email protected]> (supplier of updated tomcat9 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Tue, 24 Nov 2020 08:21:29 +0100
Source: tomcat9
Architecture: source
Version: 9.0.40-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Java Maintainers 
<[email protected]>
Changed-By: Emmanuel Bourg <[email protected]>
Closes: 926338 966338
Changes:
 tomcat9 (9.0.40-1) unstable; urgency=medium
 .
   [ Emmanuel Bourg ]
   * New upstream release
     - Refreshed the patches
   * Changed the home directory of the tomcat user to /var/lib/tomcat
     (Closes: #926338)
 .
   [ Vincent McIntyre ]
   * Automatically export the JAVA_HOME environment variable when the value
     is defined in /etc/defaults/tomcat9 (Closes: #966338)
Checksums-Sha1:
 477c9f9b1fabf43776a8af043b68cfe9868d6b87 2748 tomcat9_9.0.40-1.dsc
 d2cf0e74fadd0798ad4f68be96a39a1fe7948110 3933592 tomcat9_9.0.40.orig.tar.xz
 a389309765f7dd4d72ef6f7bddf12d6009803b99 33700 tomcat9_9.0.40-1.debian.tar.xz
 e64eb8139a592b58a8de35fb808cf13e82273e7c 13485 
tomcat9_9.0.40-1_source.buildinfo
Checksums-Sha256:
 44ef26ba4b56134bce0a88351aa60c8cf64801fd0daf41fe8702fb099fad07d8 2748 
tomcat9_9.0.40-1.dsc
 f0075897d1cee6c8f43a96bace03a8b9537c78a5ca69936c899002ae06878802 3933592 
tomcat9_9.0.40.orig.tar.xz
 1deafd4a3b1e58d0c769d0d81b1beef1b0c371a0f977b5a0f2b12dbd8e84358b 33700 
tomcat9_9.0.40-1.debian.tar.xz
 bc404ebd810cc24bff034cbb8f88a4f8e830385d586c0e10d8f7759a98e8eebd 13485 
tomcat9_9.0.40-1_source.buildinfo
Files:
 d0817f4521316ed7f9dd39efde40896e 2748 java optional tomcat9_9.0.40-1.dsc
 5c184b3b4583b3f90f5e22c045925fab 3933592 java optional 
tomcat9_9.0.40.orig.tar.xz
 6c642b4ea18981c20beecf18e908fab7 33700 java optional 
tomcat9_9.0.40-1.debian.tar.xz
 9ec2922e4ccde077f0dd2bcd24e2f730 13485 java optional 
tomcat9_9.0.40-1_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJGBAEBCgAwFiEEuM5N4hCA3PkD4WxA9RPEGeS50KwFAl+8tKUSHGVib3VyZ0Bh
cGFjaGUub3JnAAoJEPUTxBnkudCsYJEP/A3Rn9SYFuR6gaxCCa0afOs8V4jO6lTP
DI3Z+0Eva3cYCOFGKs0c/mNCEhbCAwsVQUQ+sAnFV7M0oLv+20pmYzeSrwBHbiBm
/oce+HUFfqGv2yHjnGDXi7qrUa+r7lRdKq/y3+9bOvMsWVbML/Z5b7XV/6W5MeqM
giwId0WWO9KVrCnfF6wWC4/ZooIGBzd2UOL7BF+5g6sHMfux4otyi+gOk4L+8sOv
J6y9J6svDCzkn+Gfq6fzee5zRzvdPCAwAWpg93wRFTmiKPg2RkbuO1qTwBxxVDpX
2tVcjp0JbiT3RPisf2VMD1qJIXnaM9ANyIUl0cc56kIZo64gCVC5mn2eLwCGNwiC
PtUzXGOVcUO/j0XwZMfXITG4gV2WpbXYSKIPHajKT1QkIFcWoH9sA41A75OCK+DR
WeGKiX/CnugLxjaChvT7wTpNyuE5hTA1fkk9A4Pps5CA5L6//Z0EP90Cba7rHGle
J9i1mmRp0hFbAP5wW8RvUu2dpkQ2KV+DBnS2gR43/ktBmvEpQeeeZZXUuD1fIL5+
1tN3tZTwXO2gGafAEmJVu7jfpJl211HTZInbHnHUqzTHOuWlhpAUv7XaJ5rGmDQX
0vuwDG3y/9Oqq1SwROaQbJDgkQMWpmFAOkYZUe1/X4nX25TMp5FB8ujVXVkFcvYh
ceMv02puOnKw
=0kqi
-----END PGP SIGNATURE-----

--- End Message ---
__
This is the maintainer address of Debian's Java team
<https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-java-maintainers>.
 Please use
[email protected] for discussions and questions.

Reply via email to