Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java web-app cannot compile with JDK 24: java: java.lang.ExceptionInInitializerError , com.sun.tools.javac.code.TypeTag :: UNKNOWN

I have file maven.pom

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
</dependency>

I use many JDKs (Adoptium, Amazon Correcto) but did not success. Error

java: java.lang.ExceptionInInitializerError
com.sun.tools.javac.code.TypeTag :: UNKNOWN

enter image description here

How to fix it?

like image 867
Do Nhu Vy Avatar asked Oct 30 '25 17:10

Do Nhu Vy


2 Answers

Lombok 1.18.38 is the the supported version for JVM 24.

Please modifiy your pom.xml as;

    <properties>
        <java.version>24</java.version>
        <lombok.version>1.18.38</lombok.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin> 
        </plugins>
    </build>

PS: Plugin part is to overcome following error;

java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTag :: UNKNOWN`

Reference: https://github.com/projectlombok/lombok/issues/3772#issuecomment-2783304578

like image 115
Jonny Lee Avatar answered Nov 01 '25 07:11

Jonny Lee


I researched many days. Because Lombok did not support, even latest version of Lombok at the time of writing is

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.36</version>
    <scope>provided</scope>
</dependency>

(did not work)

enter image description here

. Please wait next release. See https://github.com/projectlombok/lombok/tags

https://github.com/projectlombok/lombok/pull/3840 (Please keep this question and answer, it will help many others who looking for solution, exactly looking for reason why error happens).

More information: Even use JDK 24, and set Java language level is 23, it will still cause error, must use JDK 23 with Java language level 23 with latest version of Lombok (at the time of writing).

like image 34
Do Nhu Vy Avatar answered Nov 01 '25 05:11

Do Nhu Vy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!