Bug 239892

Summary: www/tomcat9: Support Java 9+
Product: Ports & Packages Reporter: Greg Lewis <glewis>
Component: Individual Port(s)Assignee: Greg Lewis <glewis>
Status: Closed FIXED    
Severity: Affects Some People CC: tommyhp2, vvd
Priority: --- Keywords: feature, needs-qa
Version: LatestFlags: vvd: maintainer-feedback+
Hardware: Any   
OS: Any   
Attachments:
Description Flags
rc script patch
none
Java 9+ support in tomcat9
vvd: maintainer-approval+
Java 9+ support in tomcat85
vvd: maintainer-approval+
Java 9+ support in tomcat85
vvd: maintainer-approval+
Java 9+ support in tomcat9 and update to 9.0.24 vvd: maintainer-approval+

Description Greg Lewis freebsd_committer freebsd_triage 2019-08-15 22:08:18 UTC
Created attachment 206601 [details]
rc script patch

The rc script for tomcat9 starts Java with the option:

-Djava.endorsed.dirs='${_tomcat_catalina_home}/endorsed'

On Java 9 and above, this will cause the JVM (and hence Tomcat) to not be able to start.  See, e.g.,

https://docs.oracle.com/javase/10/migrate/

(Particularly "Removed Endorsed Standards Override Mechanism")

The attached patch detects the Java version and only passes this option to Java if the version is less than 9.  A similar patch should likely also be applied to other Tomcat versions (e.g. tomcat85)
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-15 22:26:58 UTC
(In reply to Greg Lewis from comment #0)
Did you forget pkg-plist diff or why did you add this line in Makefile: "JAVA_VERSION=${JAVA_PORT_VERSION}"?
Comment 2 Greg Lewis freebsd_committer freebsd_triage 2019-08-16 15:00:00 UTC
That was to substitute for %%JAVA_VERSION%% in the change to the rc script.

It's not strictly necessary though.  I could instead default the version to empty if it doesn't get determined and remove that change from the Makefile if you'd prefer.
Comment 3 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-18 02:06:38 UTC
(In reply to Greg Lewis from comment #2)
There are no %%JAVA_VERSION%% in files/tomcat9.in…
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-18 02:08:15 UTC
(In reply to VVD from comment #3)
Oh! Found it…
Comment 5 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-18 02:24:22 UTC
(In reply to VVD from comment #4)
Java version must be runtime detected, but not build time.
Can you fix this in patch?
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-18 02:59:27 UTC
Created attachment 206651 [details]
Java 9+ support in tomcat9

Plz, test this patch.
It work for me on 12.0 amd64 with openjdk8 and openjdk11.
Comment 7 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-18 03:00:01 UTC
Created attachment 206652 [details]
Java 9+ support in tomcat85

Same for tomcat85.
Comment 8 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-18 03:10:33 UTC
I found other way to check java version:
> java -version 2>&1 | awk -F '"' '/version/ {print $2}'
What is more correct way?

> java -version 2>&1 | head -1 | sed -e 's/[^"][^"]*\"\([^\"]*\)\".*/\1/'
Comment 9 Greg Lewis freebsd_committer freebsd_triage 2019-08-19 17:08:32 UTC
I don't think one way is more correct than the other, they're just a different way of essentially doing the same thing.  I'm ok with either.  If you prefer the awk version then I have no problems with that.  It is certainly shorter.
Comment 10 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-21 22:06:29 UTC
Created attachment 206767 [details]
Java 9+ support in tomcat85

Replaced to awk version with full path.
Comment 11 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-21 22:23:42 UTC
Created attachment 206768 [details]
Java 9+ support in tomcat9 and update to 9.0.24

Replaced to awk version with full path.

Also updated to version 9.0.24:
http://tomcat.apache.org/tomcat-9.0-doc/changelog.html#Tomcat_9.0.24_(markt)
Comment 12 Walter Schwarzenfeld freebsd_triage 2019-08-21 22:36:54 UTC
*** Bug 238067 has been marked as a duplicate of this bug. ***
Comment 13 commit-hook freebsd_committer freebsd_triage 2019-08-22 02:41:41 UTC
A commit references this bug:

Author: glewis
Date: Thu Aug 22 02:40:40 UTC 2019
New revision: 509574
URL: https://svnweb.freebsd.org/changeset/ports/509574

Log:
  * Update to 9.0.24
  * Support Java 9+ by not setting java.endorsed.dirs for those versions

  PR:		239892
  Submitted by:	vvd@unislabs.com (maintainer)

Changes:
  head/www/tomcat9/Makefile
  head/www/tomcat9/distinfo
  head/www/tomcat9/files/tomcat9.in
Comment 14 commit-hook freebsd_committer freebsd_triage 2019-08-22 02:46:43 UTC
A commit references this bug:

Author: glewis
Date: Thu Aug 22 02:46:32 UTC 2019
New revision: 509575
URL: https://svnweb.freebsd.org/changeset/ports/509575

Log:
  * Support Java 9+ by not setting java.endorsed.dirs for those versions

  PR:		239892
  Submitted by:	vvd@unislabs.com (maintainer)

Changes:
  head/www/tomcat85/Makefile
  head/www/tomcat85/files/tomcat85.in
Comment 15 Greg Lewis freebsd_committer freebsd_triage 2019-08-22 02:47:09 UTC
Thanks!  I've committed both final patches you provided.
Comment 16 Vladimir Druzenko freebsd_committer freebsd_triage 2019-08-22 09:36:59 UTC
Thanks!