Monday 5 December 2022

Migrating a project from Java 11 to Java 17

Java 17 is new LTS version and it make sense to migrate existing projects to the new version. I will describe my specific case


1) So first I updated maven pom.xml and put there - <java.version>17</java.version>

2) Next I updated docker image - to this one - openjdk:17

3) In dependencies I have spring boot so updated it to version 2.6.8 

4) There were some difficulties with Ignite Cache, we should use previous version that uses some features from previous jdk that why I added this vm options to open access to closed packets:


                org.apache.maven.plugins
                maven-surefire-plugin
                3.0.0-M7
                
                    --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
                        --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
                        --add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED
                        --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
                        --add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
                        --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
                        --add-opens=java.base/java.io=ALL-UNNAMED
                        --add-opens=java.base/java.nio=ALL-UNNAMED
                        --add-opens=java.base/java.util=ALL-UNNAMED
                        --add-opens=java.base/java.lang=ALL-UNNAMED
                        --add-opens java.base/java.time=ALL-UNNAMED
                    
                
            

5) We need to add the same options in java opts when we starting our application, we use docker how i said so i created JAVA_OPTS vars with props above, and added to docker run
ENTRYPOINT java $JAVA_OPTS -jar super-project.jar
6)  Next there were some issues with swagger that why I updated to springdoc-openapi-ui 1.6.11

7)  I've spent a lot of time to resolve issue with Jaeger tracing, it was disabled locally and everything was ok but when we start our app on server we have exceptions. So we decided to move from jaeger to spring-cloud-starter-sleuth - 2021.0.2 

In general, these are the most notable bugs I encountered during the migration to Java 17 which I found useful to mention. So it is not scary at all)

No comments:

Post a Comment