Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7.0.73 doesn't work with java 9

Tags:

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?

like image 506
learner Avatar asked Aug 28 '17 10:08

learner


People also ask

What version of Java does Tomcat 7 use?

Building Apache Tomcat requires a Java 6 JDK to be installed and optionally a Java 7 JDK installed in parallel with Java 6 one. The Java 7 JDK is only required if you wish to build Tomcat with JSR-356 (Java WebSocket 1.1) support.

Is Tomcat 7 still supported?

Tomcat 7 reached End-of-Support on 23 March 2021.

Which Tomcat version is suitable for Java 8?

Latest stable version supported on Java 8 is Tomcat 10 but the users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax. * to jakarta.

Why is my Tomcat not working?

Most common issue with Tomcat note starting is that Java is not configured properly, user trying to start Tomcat does not have permissions to do so, or another program is using port 8080 on that server.


2 Answers

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.

like image 182
Christopher Schultz Avatar answered Oct 23 '22 23:10

Christopher Schultz


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.

like image 21
Mak_Amit007 Avatar answered Oct 24 '22 01:10

Mak_Amit007