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.
Related
Recently I updated my JDK from 8 (1.8_275) to 11 (openjdk version "11.0.9.1" 2020-11-04)
While I am trying to launch SCDF local server using
java -jar spring-cloud-dataflow-server-local-1.7.4.RELEASE.jar
It had no issues at all while I used JDK 8. But with JDK 11, I am getting below exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
javax/xml/bind/JAXBException
I looked here and here. Even trying (with --add-modules java.xml.bind):
java -jar spring-cloud-dataflow-server-local-1.7.4.RELEASE.jar --add-modules java.xml.bind
results in the same error as mentioned above.
I understand, as per this, it is removed in JDK 11. But What I am missing here? I mean how can I make it work or what is work around for this?
You're using an ancient and deprecated version of SCDF. The 1.x version of SCDF has reached EOL/EOGS, as well. In particular, the version you're using is >2yrs old.
Please upgrade to the 2.x version. The latest GA is at 2.7.0.
Check out the getting-started guide and the release blog for more details.
You could try running without internet connection. They didn’t update the pre-built jars properly and it must be behind a firewall also. Try kubernetes too.
We are moving from Java 8 to 11 on a project using jaxb. As it has been removed from the JDK, it has to be included separately, which I have done via gradle config:
compile("javax.xml.bind:jaxb-api:2.2.11")
compile("com.sun.xml.bind:jaxb-core:2.2.11")
compile("com.sun.xml.bind:jaxb-impl:2.2.11")
I am able to run the project, however compileJava gradle job throws errors:
Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\db0f76866c6b1e50084e03ee8cf9ce6b19becdb3\jaxb-core-2.2.11.pom:
'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-core:2.2.11
Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\2d4b554997fd01d1a2233b1529b22fc9ecc0cf5c\jaxb-impl-2.2.11.pom:
'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-impl:2.2.11
The job finishes and there is a jar created, however when run on production server it stops with this error:
java.lang.NoClassDefFoundError: javax/xml/bind/Unmarshaller$Listener
I'm using Spring Boot v1.5.6 and gradle 4.8.1
The solution is to use a newer version of the jaxb libraries. 2.3.0 is no longer using tools.jar.
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.
I need to compile a an eclipse RCP using maven+tycho, at the moment everything is working fine, as I configured this on my local PC.
When switching to production-building configuration, it fails, the only difference being java version used.
Works with: Java jdk1.8.0_25
Fails with: Java jdk1.6.0_45
Error message:
ATTENTION: Error injecting: org.eclipse.tycho.core.p2.P2ArtifactRepositoryLayout
java.lang.TypeNotPresentException: Type org.eclipse.tycho.core.p2.P2ArtifactRepositoryLayout not present
...
...
...
Caused by: java.lang.UnsupportedClassVersionError: org/eclipse/tycho/core/p2/P2ArtifactRepositoryLayout : Unsupported major.minor version 52.0
I can provide the full error stack if needed, but the error message seems pretty explicit already. Still, didn't find anything about it on the web, because it feels strange that this can't be done using java 1.6.
When using java jdk 8, I don't have any errors and the build is working fine till the end.
Recent versions of Tycho require Java 8 (.class file version 52.0 means Java 8). You can, however, still build against an older Java (and run tests with an older Java) using a feature called toolchains. That way, mvn runs on Java 8, while your code is compiled against Java 6.
i have a osgi project in indigo ide, which use equinox 3.7.0 + jetty 7.5.1, now i upgrade ide to juno, which contain equinox 3.8.0 + jetty 8.1.3, so,
the tragedy go on:
when compiling, complain accesible restrictation on SslContextFactory's methods, i resolved it by editing it's access rules in build path.
when running, have a error, say
java.lang.NoClassDefFoundError: org/eclipse/jetty/util/ssl/SslContextFactory
now i have no idea, thanks for ur help.
The access rules are there for a reason.... by hiding the build-time error, you just made the runtime error appear.
The proper solution is to import the package org.eclipse.jetty.util.ssl in your bundle.
If you use a tool such as Bndtools then these Import-Package dependencies will be detected and generated automatically.