Java

How to migrate from Oracle Java 8 to OpenJDK 11

0
(0)

Recently I finished migrating my application from Java 8 to OpenJDK 11. Here are few steps where we got stuck and the solutions that helped us.

Problem No 1 – JVM argument UseFastAccessorMethods  argument is not supported anymore in OpenJDK 11

Solution – Removed this JVM argument from batch scripts/shell scripts.

Further Readinghttps://bugs.java.com/bugdatabase/view_bug.do?bug_id=6385687

Problem No 2 – com.myApp.configuration.Module class conflicts with java.lang.Module class introduced in OpenJDK 11. Basically I had a class called Module which was now conflicting with java.lang.Module class introduced in OpenJDK 11.

Solution – Explicitly import com.myApp.configuration.Module class in required classes.

Further Readinghttps://docs.oracle.com/javase/9/docs/api/java/lang/class-use/Module.html

Problem No 3 – Compile/Runtime issues with commons-lang:commons-lang:2.1@jar

Solution – Upgraded to commons-lang:commons-lang:2.6@jar

Problem No 4

Jersey Rest APIs were not working (Runtime issue) with following libraries
‘org.glassfish.jersey.core:jersey-client:2.16@jar’
‘org.glassfish.jersey.core:jersey-common:2.16@jar’
‘org.glassfish.jersey.containers:jersey-container-servlet:2.16@jar’
‘org.glassfish.jersey.containers:jersey-container-servlet-core:2.16@jar’
‘org.glassfish.jersey.bundles.repackaged:jersey-guava:2.16@jar’
‘org.glassfish.jersey.media:jersey-media-jaxb:2.16@jar’
‘org.glassfish.jersey.core:jersey-server:2.16@jar’

Solution

Migrated these libraries to below libraries. Post this upgrade Jersey APIs were working fine ‘org.glassfish.jersey:jersey-bom:2.27’ 
‘org.glassfish.jersey.containers:jersey-container-servlet:2.27’
‘org.glassfish.jersey.inject:jersey-hk2:2.27’
‘org.glassfish.jersey.core:jersey-client:2.27’

‘org.glassfish.jersey:jersey-bom:2.27’ 
‘org.glassfish.jersey.containers:jersey-container-servlet:2.27’
‘org.glassfish.jersey.inject:jersey-hk2:2.27’
‘org.glassfish.jersey.core:jersey-client:2.27’

Problem No 5 – Library com.sun.xml.messaging.saaj missing in OpenJDK 11 which was part of Oracle Java 8. This is used in SOAP

Solution – Explicity import library ‘com.sun.xml.messaging.saaj:saaj-impl:1.3.20’

Further Readinghttps://javaee.github.io/metro-saaj/

Problem No 6 – Library com.sun.org.apache.xml.internal:resolver missing in OpenJDK 11 which was part of Oracle Java 8.

Solution – Explicitly import library compile group: ‘com.sun.org.apache.xml.internal’, name: ‘resolver’, version: ‘20050927’

Further Readinghttps://stackoverflow.com/questions/3889308/xml-catalog-resolving-resolver-jar-vs-com-sun-org-apache-xml-internal-resolver

Problem No 7 – Gradle compilation fails since JAVA_HOME was pointing to older Oracle Java 8 JDK

Solution – Changed JAVA_HOME environment variable to point to new OpenJDK 11

Problem No 8 – Tomcat was not starting since JRE_HOME was pointing to older Oracle Java 8 JDK

Solution – There is no JRE in OpenJDK 11. So we have to remove JRE_HOME variable

I encountered few more problems, will list the solutions soon on this page for those as well. I have tested my application on Windows 10 and CentOS 6 and 7.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Tagged ,
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments