Tomcat 7.0.73 doesn't work with java 9
Asked Answered
Q

8

23

Unable to start tomcat based app with java 9 because of default "java.endorsed.dirs" option in catalina.sh.

-Djava.endorsed.dirs=/usr/local/share/tomcat/endorsed is not supported. Endorsed standards and standalone APIs in modular form will be supported via the concept of upgradeable modules. 
Error: Could not create the Java Virtual Machine. 
Error: A fatal exception has occurred. Program will exit.

Is there a work around for this?

Quiescent answered 28/8, 2017 at 10:59 Comment(1)
Well, looking for a solution to this SO question, I had realized and raised another SO, which all boilled down to the point that with java 9, you need to use Tomcat 9 for adaptibility reasons. In short try out executing your application with apache-tomcat-9.0.0.M26 and jdk-9+181 to figure out exact failures .Closehauled
O
29

You'll have to hack the script bin/catalina.sh to get this to work.

There are a bunch of lines like this in bin/catalina.sh:

  exec "$_RUNJDB" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
    -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
    ...

Just remove the second of those lines (the one with -Djava.endorsed.dirs) in each case and you should be back in business.

I'm looking at improving those scripts so that -Djava.endorsed.dirs is not provided to the JVM when the value is empty (which should be the case if you are using Java 9).

UPDATE 2017-11-06

Looks like r1810284 should fix the endorsed.dirs problem. Expect this fix to be included in Tomcat 7.0.83 (or whatever the next 7.0.x version passes voting).

UPDATE 2018-03-07

The first official release of Apache tomcat 7.0.x that includes this fix is Apache Tomcat 7.0.84, voted stable on 2018-01-24.

Outface answered 28/8, 2017 at 14:12 Comment(13)
a similar check was implemented by the WTP folks at bugs.eclipse.org/bugs/show_bug.cgi?id=507338 If you have not already changed catalina.sh, I can volunteer a patch for it.Mesolithic
@Mesolithic Patches always welcome! Post to users list or fork+PR on Github.Outface
I have added a PR on github - github.com/apache/tomcat70/pull/13Mesolithic
I took back the PR because the latest code seems to take care of it already. When can we expect the next 7.x release?Mesolithic
@Mesolithic Thanks for the contribution, anyway. Feel free to make additional PRs against Tomcat or any other ASF project. Bugzilla is a good place to find low-hanging fruit which we intentionally leave available as introductions for new contributors. Join the user and dev mailing lists if you'd like to get more involved.Outface
Still a problem in Tomcat 7.0.82.Poet
Looks like r1810284 should have fixed the endorsed.dirs problem. Tomcat 7.0.82 was released as r1810087 so I think this fix simply hasn't yet been released.Outface
I am just wondering if there is any recommendation from tomcat vendor to not use tomcat 7 with java 9.Quiescent
There is no particular reason not to use Tomcat 7 on Java 9. If you find that something is not working, please report it on the Tomcat users' mailing list and it should be corrected.Outface
On the other hand, if you are aggressively moving towards Java 9, why not also consider upgrading to Tomcat 8.5 or Tomcat 9?Outface
Can anybody tell me, is planned TomEE version with this Tomcat patches?. My goal is production (more or less) quality package, cannot administer manually multiple installations.Unstained
@JacekCz You'd have to ask the TomEE community. Best place is their users' mailing list.Outface
I had this issue upgrading our Jenkins server from java 8 to open jdk11. Fix worked perfect for us.Health
Z
4

The above issue was fixed with the later releases of Eclipse but Unfortunately, it appeared again with the release of Java 10. Here is my research : Initially, I installed Java 10 and Eclipse Oxygen 3 which gave me the same error you mentioned in your question. But, at the moment I installed Java 9 and pointed my Apache tomcat runtime server to it, the error was gone.

Zingaro answered 29/3, 2018 at 16:18 Comment(1)
Support for Java 10 and above was fixed in later releases.Sellingplater
N
2

In my case, what I did to answer the problem of Tomcat not running was to set Tomcat (version 7) with a lower Java version (e.g. Java 8).

Then, in startup.sh, shutdown.sh and catalina.sh I added the following:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`;
Nopar answered 16/2, 2018 at 8:56 Comment(3)
I want to run with java9+ version and hence this solution will not work for me but as we are editing catalina.sh then we can simply add code to remove endorsed dir property completely as suggested above.Quiescent
thank you, I just did this a couple of minutes ago, the above comment is out of my league(sorry)...I just leave my comment for those who just upgraded their java version to 9 and find their tomcat7 not working...Nopar
It would be better to modify (or create, if it doesn't exist) conf/setenv.sh instead of modifying any of the scripts that ship with Tomcat.Outface
D
2

To fix this bug, you need to install/update the Eclipse Web Tools Platform (WTP) to version 3.9.4 or later.

Select Help > Install new Software... Select or add following URL: http://download.eclipse.org/webtools/repository/oxygen Check Web Tools Platform (WTP) 3.9.4 Select "Next" and follow instructions

Reconfigure the tomcat in eclipse.

Downe answered 3/8, 2018 at 6:54 Comment(1)
Support for Java 10 and above was fixed in later releases.Sellingplater
H
2

This symptom can come about if you have a Tomcat Runtime using a JRE earlier than Java 9 and create and run a server with that runtime. Then edit the Tomcat Runtime to use Java 9 and try to start the server. What happens is that a "-Djava.endorsed.dirs" argument gets added to the launch configuration when the server was run with the earlier JRE. When running the server after the switch to Java 9, the "-Djava.endorsed.dirs" argument is seen as a user added VM argument and kept, resulting in the error.

The simplest way to fix is to recreate the server. You can also right click on the server in the servers view and select Open. In the window that opens, click the "Open launch configuration" link at the bottom of the General section. In the dialog that opens, switch to the Arguments tab and in the "VM arguments" section, edit out the "-Djava.endorsed.dirs" argument and click OK. You should be able to start the server now.

Haul answered 30/10, 2018 at 18:50 Comment(0)
M
1

In Run configurations -> Arguments -> VM arguments try removing

-Djava.endorsed.dirs="C:\Program Files\Apache Software Foundation\Tomcat 8.5\endorsed"

Merous answered 28/6, 2020 at 12:37 Comment(0)
I
0

You have to remove -

"-Djava.endorsed.dirs="/home/ttlaptop/Downloads/apache-tomcat-7.0.105/endorsed"

from run configurations, and then tomcat will start

Inspissate answered 26/8, 2020 at 20:41 Comment(0)
M
-2

I can't be sure but ..

Step 1 -- > it worked for me, I just remove servers from eclipse

Step 2 --> restarted and add server again (tomcat 7) Tomcat v7.0 Server at localhost

Malvia answered 31/5, 2020 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.