NoClassDefFound after updating to OpenJDK16?
Soamid opened this issue · comments
Hello,
I've been using launch4j in my gradle projects for a bunch of years. Last year we migrated from JDK8 to OpenJDK14 (without any lanuch4j related problems) and recently we wanted to bump JDK to 16. However, when I run gradlew clean build createExe
on OpenJDK 16 I receive the following error:
Execution failed for task ':createExe'.
> Could not initialize class net.sf.launch4j.config.ConfigPersister
Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.launch4j.config.ConfigPersister
at edu.sc.seis.launch4j.tasks.Launch4jLibraryTask.run(Launch4jLibraryTask.groovy:42)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
...
I had to update Gradle to 7.0-RC2 version, but it seems to work when I run Gradle7 + JDK14, it stops only when I change JDK.
I am using Gradle launch4j plugin 2.4.9. I was able to reproduce this behaviour on 2 different cases (multi-project and single-project).
Is this the only exception you got running your build with jdk 16?
Yes, it is the only exception when I run the build with --stacktrace
option.
However, I looked deeper into the launch4j code and I have a clue - it might be nothing, but it's worth noting: ConfigPersister
uses XStream library. In 2.4.9 version of the plugin, XStream version is 1.4.11.1. In my another project I'm also using XStream and during migration JDK14 -> 16 it started throwing InaccessibleObjectException
exception. I had to bump it to 1.4.16 and then it worked again.
Update: upgrading launch4j plugin to the (just released) version 2.5.0 apparently resolved the problem. :)