openjdk11 + gradle classcastexception - gradle

I have downloaded gradle 7.5 in (RHEL server) and trying to use with openjdk11. Getting issue as below
openjdk installed using RHEL yum
" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$PlatformClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$PlatformClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap'"

Related

JBehave Serenity Jenkins issue

I am trying to run Jbehave Serenity test in jenkins server but getting below error java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Lorg.jbehave.core.reporters.Format; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Lorg.jbehave.core.reporters.Format; is in unnamed module of loader org.apache.maven.surefire.booter.IsolatedClassLoader #7ef0e035).
Tried updating serenity plugins based on: Error while running JUnit Test, it did not resolve. We are still using Java 8

Why is `${maven.projectBasedir}/.mvn/jvm.config` taken into account only when the fork count is equal to zero during the tests?

I use Maven 3.8.1 and Maven surefire plugin 3.0.0-M5 with OpenJDK 16. .mvn/jvm.config contains --add-opens=java.base/java.lang=ALL-UNNAMED in order to fix the following error:
java.lang.reflect.InaccessibleObjectException: Unable to make
protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does
not "opens java.lang" to unnamed module #319aa9ee
Why do I need to pass -DforkCount=0 to Maven to make it work? .mvn/jvm.config seems to be ignored when I run mvn install alone without forcing the unforked VM. Is there a cleaner solution?
You can reproduce my problem by using the following project:
https://jogamp.org/cgit/ardor3d.git/
P.S: The problem is caused by EasyMock 4.3. It uses Objenesis under the hood which claims to support Java 16, it's supported with some tweaks, it's a known concern. sun.misc.Unsafe is mentioned but not the method above.
P.S 2: A stack trace mentions cglib which doesn't support Java 17 yet:
Caused by: org.easymock.cglib.core.CodeGenerationException:
java.lang.reflect.InaccessibleObjectException-->Unable to make
protected final java.lang.Class
java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
throws java.lang.ClassFormatError accessible: module java.base does
not "opens java.lang" to unnamed module #2064d52f
Reference:
https://maven.apache.org/docs/3.8.1/release-notes.html#JVM_and_Command_Line_Options

java.lang.ExceptionInInitializerError is produced when lombok is used within a Spring-boot application

When I am using lombok within a spring-boot application java: java.lang.ExceptionInInitializerError is produced. What can I do to prevent this error?
What have I done?
I've installed lombok plugin in IntelliJ and restarted it after installing plugin.
I've enabled Annotation Processors from both
File->Setting and Filer->Other Setting->Default-> setting->Build, Execution and deployment->Compiler->Annotation Processors
File->Setting and Filer->Setting->Build, Execution and deployment->Compiler->Annotation Processors
I've also tried to change the scope of dependency in the pom.xml to 'provided'
I tried other versions of lombok such as 1.16.21, 1.14 and ... but when I change the version other errors occur (For example when I change the version to the 1.16.16, Compiler says 'java package lombok dose not exists.')
Errors with different versions:
1.16.21: java.lang.ExceptionInInitializerError
1.16.20: java.lang.ExceptionInInitializerError
1.16.19: java.lang.ExceptionInInitializerError
ver < 1.16.18: java: package lombok does not exist
other info:
JDK: 10
Spring-boot: 2.0.2.RELEASE
OS: Windows and Linux
The amount of boilerplate code (setter and getters) is really high in my code, and I really need lombok what can I do to use it?
.
The problem has been solved in Lombok version 1.18.0
There is known issue with lombok and Java 10: https://github.com/rzwitserloot/lombok/issues/1572. Should be fixed with 1.16.22 version.

e(fx)clipse runnable jar export - javafx.application.Application class not found

I'm coding a JavaFX app using eclipse Oxygen and e(fx)clipse plugin running on debian 9 (stretch).
I've exported it as a runnable jar.
When launching an error is raised:
java -jar myapp.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application
I fixed the issue :
in eclipse my java compiler was java-se 8 but I was using open-jdk 8 in my own desktop environment. Changing my java environment using
sudo update-alternatives --config java
to java-se 8 solved the problem.

How do I include a java 9 module at runtime?

I have a server kit that I'm trying to test on the java9 JDK (found here, I'm using the 64-bit Linux version), however I'm encountering the following error shortly after startup:
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:533)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:186)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:476)
The server kit starts without issue when using java8. Somehow I need to tell the runtime system to include the javax.xml.bind module, however I'm new to java9 and don't know how to do this short of recompiling the entire server kit into a module and adding a dependency on the javax.xml.bind module. Is there a way to resolve this error that doesn't require me to recompile the server kit into a module?
Java EE modules are shipped with the JDK but not resolved by default and java.xml.bind is one of them. In such cases they need to be included explicitly with --add-modules.
In your case, launch with --add-modules java.xml.bind.

Resources