Java build has started failing - Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor
Asked Answered
B

8

35

We have a Java 11 server on EC2 that has just started failing to build with the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) 
on project showhow-server: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x49d0e934) cannot access class 
com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler 
does not export com.sun.tools.javac.processing to unnamed module @0x49d0e934 -> [Help 1]
[ERROR] 

The build is from BitBucket pipelines.

Any idea what it could be?

Babs answered 24/3, 2021 at 23:21 Comment(0)
S
78

Upgrade lombok dependency to 1.18.20

Sabotage answered 4/4, 2021 at 16:37 Comment(4)
With java 11 changing the lombok version from 1.18.16 to 1.18.20 just did the trick for me. Thanks!Precise
With java 17 for arm64, this solved my error.Heaviside
With java 17 for arm64, it's working, thanks.Burgwell
It solved my problem in Java-11 and maven 3.8.1 combination for the lombak.Kriss
W
6

I use java 11 too and fixed the problem by adding this to the POM plugins section.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <fork>true</fork>
                <!-- this is to fix bitbucket pipeline build error due to Lombok processing -->
                <compilerArgs>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
                    <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
                </compilerArgs>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>

The java.verion is 11, lombok.version is 1.18.18

Wheelwork answered 29/3, 2021 at 23:57 Comment(0)
B
3

Using maven i managed to build using this (changed source and target to match my java version):

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
    <source>16</source>
    <target>16</target>
    <fork>true</fork>
    <compilerArgs>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
        <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
    </compilerArgs>
    <annotationProcessorPaths>
        <path>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.16</version>
        </path>
    </annotationProcessorPaths>
</configuration>

Source, lomboks github

Buoyancy answered 25/3, 2021 at 9:55 Comment(1)
I inform that this solution worked for me also for v11. Thank you.Carnelian
R
2
when we added below lombok dependency in pom.xml file , it worked for me

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.24</version>
    <scope>provided</scope>
</dependency>
Rosinweed answered 5/7, 2023 at 9:29 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Snakebite
F
2

Add below lombok dependency in pom.xml file,

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.24</version>
        <scope>provided</scope>
    </dependency>
Finzer answered 29/8, 2023 at 5:51 Comment(0)
G
0

i had faced same issue due to vulnerabilities in current lombok version. please verify vulnerability status of current version and if required, please upgrade it to latest working version.

Genetics answered 14/3, 2022 at 12:29 Comment(0)
H
0

in case anyone runs into this and has to change lots of maven projects to make it work (like me) you can also copy the newer lombok jar into older version's directory and rename it (i.e. lombok-1.18.26.jar to lombok-1.16.18.jar)

this was much easier than changing lombok version in 20+ projects

Hellhound answered 22/3, 2023 at 10:20 Comment(0)
G
0

just check whether you added Lombok dependency, and if you have already then try latest version. for me i am using JDK 22, and Lombok dependency " 1.18.30"

Gunthar answered 3/6 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.