4

We are planning to migrate our project from java 8(currently running on tomcat 7) to java 11, since rt.jar file is no longer available, and tomcat startup needs classes from sun.misc package for instance,sun.misc.GC. Also, our application uses javax.xml.ws.WebServiceFeature. we are getting no java.lang.NoClassDefFoundError and application fails to launch. How to get this dependencies resolved in java 11?

Anoop Deshpande
  • 273
  • 2
  • 14
  • 5
    You should not need to. All non-internal rt.jar dependencies should be available in the Java 11 JDK. And since there isn't a separate JRE anymore .... you either use a JDK or use jlink to create a custom distro. – Stephen C Nov 23 '18 at 06:06
  • 4
    If you are depending on internal APIs, you need to find replacements on a case-by-case basis. – Stephen C Nov 23 '18 at 06:07
  • 4
    too broad to say *have some dependencies*... got any specific use case to use `rt.jar` exclusively? you should share that then so as to clarify why does the existing JDK not solve your use case. – Naman Nov 23 '18 at 06:07
  • 2
    I assume you just need to upgrade tom Tomcat 9. For JAX-WS then it just means moving to the standalone download, which you can find on Maven. – Alan Bateman Nov 23 '18 at 07:58
  • Related: [*How to get java 11 run-time environment working since there is no more jre 11 for download?*](https://stackoverflow.com/q/53111921/642706) – Basil Bourque Jul 12 '19 at 23:50

2 Answers2

1

Tomcat 7 won't work with Java 11. You need to upgrade your application server to a newer version.

As the Tomcat team hasn't listed Java 11 compatibility for their products, your best bet is to take the latest release version and see if it works (hint, I did that last month and 9.0.12 works).

After that, you also need to see if your own application works under JDK 11, and whether it compiles.

Any errors you get, you need to find alternatives, often the same APIs are already available as Maven packages in the central repository.

Robert
  • 33,260
  • 14
  • 84
  • 130
jwenting
  • 4,890
  • 2
  • 22
  • 28
  • It's frustrating that the [compatibility grid in the Tomcat documentation](http://tomcat.apache.org/whichversion.html) is misleading with regard to Java. From looking at that you would reasonably assume that Tomcat 7 does work with Java 11 since the _"Supported Java Versions"_ are shown as _"6 and later"_. – skomisa Nov 25 '18 at 09:34
  • @skomisa It's not so much misleading as not updated for quite some time now. – jwenting Nov 25 '18 at 10:36
0

For the other part of your question on where to find javax.xml.ws.WebServiceFeature in Java 11... it has been moved out of rt.jar and into a different project called Glassfish Metro.

Personally I found the Glassfish Metro page to be of little help, at least in regards to telling me how to add a dependency, but I eventually figured it out. For Maven add the following to your pom file. (Version 2.3.1 worked for me. It looks like the latest is version 2.4.3.)

<dependency>
    <groupId>org.glassfish.metro</groupId>
    <artifactId>webservices-rt</artifactId>
    <version>2.3.1</version>
</dependency>

Info for other dependency management tools can be found at

https://mvnrepository.com/artifact/org.glassfish.metro/webservices-rt/2.3.1 https://search.maven.org/artifact/org.glassfish.metro/webservices-rt/2.3.1/jar

HairOfTheDog
  • 1,948
  • 1
  • 22
  • 28