How get rt.jar dependencies in java 11?
Asked Answered
T

2

7

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?

Thought answered 23/11, 2018 at 5:59 Comment(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.Cammie
If you are depending on internal APIs, you need to find replacements on a case-by-case basis.Cammie
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.Riella
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.Therese
Related: How to get java 11 run-time environment working since there is no more jre 11 for download?Fabron
I
2

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.

Instate answered 23/11, 2018 at 8:25 Comment(2)
It's frustrating that the compatibility grid in the Tomcat documentation 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".Chetnik
@Chetnik It's not so much misleading as not updated for quite some time now.Instate
P
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

Pneumatophore answered 28/1, 2019 at 23:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.