How get rt.jar dependencies in java 11?

15.9k views Asked by At

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?

2

There are 2 answers

2
jwenting On

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.

0
HairOfTheDog On

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