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

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.

Related

Unknown property generateLombokConfig.enabled after ugrading gradle from 6.9 to 7.3

I have a property called generateLombokConfig.false in the code which I received.
The code was built for java 8. Now am upgrading it for Java 17. When I upgrade to Java 16 compatible version of Gradle (7.3) , Lombok (6.3), the code fails to build with error
Could not get unknown property 'generateLombokConfig' for root project 'myapp' of type org.gradle.api.Project
Is this property deprecated? Is it safe to remove ? I dont find any information in the docs.
Looks like it is deprecated and removed from the latest Lombok version. No helpful documentation apart from this javadoc

spring boot application with JDK 14 fails to start. no error either

I am upgrading
(JDK 8 + spring boot application (2.1.0.RELEASE)) TO
(JDK 14 + spring boot application (2.3.3.RELEASE))
I am using --enable-preview as part of java command but it silently fails. can't see any logger stmts either. --verbose option is not throwing any error nor warning.
any help?
Thanks for responses. Here are more details.
I use maven to compile and use java directly to run it (thru a shell script) java -jar ./target/fat_00.1.jar
Why I am doing both (spring FM + JDK) at same time?
upgrading JDK kind of forced me to upgrade SFM 2.1 to 2.3 (latest)
what else I tried?
I tried "--enable-preview" while compiling (by changing maven pom maven-compiler-plugin plugin) and adding to "java" command prompt
** java -verbose --enable-preview -jar ./target/fat_00.1.jar**
But none of them give any clue. biggest problem is my spring application exits without any error.
IF I upgrade ONLY spring FW keeping JDK1.8 I get following error:
findById(java.lang.Long) in com.model.repository.MyRepository clashes with findById(ID) in org.springframework.data.repository.CrudRepository
I understand the error its throwing, but does it mean it has no backward compatibility?
How do I find what's going on? without any error thrown anywhere, it is really frustrating.

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.

Camel Compatibility issues

I am using the following camel packages in my Maven project:
camel-core
camel-jms
camel-jaxb
camel-quartz
camel-bindy
camel-ftp
And when all these are using version 2.8.0 my server starts up fine and the app works ok. But if I update the camel version to anything higher like 2.10.0 then I get the following exception on startup and not sure which of these is causing this issue:
Caused by: org.apache.camel.TypeConverterLoaderException: Failed to load type converters because of: Cannot find any type converter classes from the following packages: [org.apache.camel.component.file.remote]
Any help would be much appreciated?
Maybe another library of your project is using a different version of camel.
You can check the camel dependency tree of your project with this maven command:
mvn dependency:tree -Dverbose -Dincludes=camel-core
In verbose mode, the dependency tree shows dependencies that were omitted for being a duplicate of another, conflicting with another's version and/or scope, and introducing a cycle into the dependency tree.
Here are some reference links:
https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html

Grails 1.2.1 with Spring 3.0.0 dependency problem under Jetty

Just moved to Grails 1.2.1 (used 1.1.1 before). Changed application.properties, ran grails upgrade, fixed BuildConfig and Bootstrap - everything works just fine from grails console.
However, getting a problem when deploy packaged war under jetty 6.1.22:
1581 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.setParameterNameDiscoverer(Lorg/springframework/core/ParameterNameDiscoverer;)V
My project is built with maven2. I researched the war dependencies and see that both spring 2.5.6 and 3.0.0.RELEASE are used there.
I then tried to suppress use of spring 2.5.6 and got a problem with Acegi plugin (using version 0.5.1):
2010-03-10 21:06:56.440:WARN::Nested in org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
Any help would be greatly appreciated.
The problem is caused by the fact that in new version of Spring
ConfigurableWebApplicationContext is located in spring-web.jar, but the interface it inherits ConfigurableApplicationContext, which contains setId(String) method is in located in spring-context.jar.
If you have a library which has been compiled against older version of spring-context it will fail with NoMethodFound exception.
The solution is to locate and recompile that library against latest Spring version.
If you are using Spring version below 3.0 you could try to put full Spring bundle Jar instead of separate packages.

Resources