How to fix "lombok.javac.apt.LombokProcessor could not be initialized"
Asked Answered
C

5

14

My question relates to "https://mcmap.net/q/334765/-gradle-build-fails-on-lombok-annotated-classes". I am using JHipster and Lombok 1.16.18 with build.gradle:

...
apply plugin: 'net.ltgt.apt'
...
dependencies {
    provided "org.projectlombok:lombok:${lombok_version}"
    apt "org.projectlombok:lombok:${lombok_version}"
}
...

but get the following error during compileJava:

warning: lombok.javac.apt.LombokProcessor could not be initialized. 
Lombok will not run during this compilation: 
java.lang.IllegalArgumentException: com.sun.tools.javac.api.ClientCodeWrapper$WrappedStandardJavaFileManager extends com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager implements javax.tools.StandardJavaFileManager

The output is:

------------------------------------------------------------ Gradle 4.2.1 ------------------------------------------------------------ 
Build time: 2017-10-02 15:36:21 UTC 
Revision: a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf 
Groovy: 2.4.12 
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 9.0.1 (Oracle Corporation 9.0.1+11) 
OS: Mac OS X 10.13.1 x86_64

What am I missing here?

Carib answered 24/11, 2017 at 12:54 Comment(3)
Please edit your question and paste output of gradlew -vArdel
------------------------------------------------------------ Gradle 4.2.1 ------------------------------------------------------------ Build time: 2017-10-02 15:36:21 UTC Revision: a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf Groovy: 2.4.12 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 9.0.1 (Oracle Corporation 9.0.1+11) OS: Mac OS X 10.13.1 x86_64Carib
https://mcmap.net/q/330619/-lombok-in-project-generated-by-spring-initializr-lombokprocessor-could-not-be-initializedMesarch
C
18

Output of gradlew -v shows that you are using JDK 9 which is not supported by JHipster 4.10.2, please use JDK 8. Same for Lombok.

------------------------------------------------------------ Gradle 4.2.1 -------
Build time: 2017-10-02 15:36:21 UTC 
Revision: a88ebd6be7840c2e59ae4782eb0f27fbe3405ddf 
Groovy: 2.4.12 
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 
JVM: 9.0.1 (Oracle Corporation 9.0.1+11) 
OS: Mac OS X 10.13.1 x86_64
Centri answered 24/11, 2017 at 14:0 Comment(0)
A
6

I was facing the similar warning in my project as we moved from JDK 8 to JDK 9.

Upgrading the lombok version helped me with removing the error.

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.20</version>
            <scope>provided</scope>
        </dependency>

I found the reference over here https://github.com/rzwitserloot/lombok/issues/1541

Anticlinal answered 15/3, 2018 at 9:39 Comment(1)
Provide context for links: Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the external resource is unreachable or goes permanently offline.Reider
P
1

if you are using gradle this has worked for me

dependencies {    annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.16'}
Punk answered 25/1, 2021 at 12:46 Comment(1)
Please read "How to Answer" and "Explaining entirely code-based answers". It helps more if you supply an explanation why this is the preferred solution and explain how it works. We want to educate, not just provide code.Reider
S
0

I had a similar problem, it turned out I was messing with my project setting and inadvertently set project JVM to 11, instead of the "correct" one, which was 8.

I reset it back to 8 and it's working again.

Sayette answered 6/4, 2021 at 12:4 Comment(0)
B
0

Make sure you have inserted the Lombok plugin inside the properties of maven.

<properties>
    <java.version>11</java.version>
    <lombok.version>1.18.8</lombok.version>
</properties>

The above arrangement worked for me instead of adding the dependency as independent dependency.

Bertina answered 17/11, 2023 at 14:49 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.