How to fix NoSuchFieldError 'com.sun.tools.javac.tree.JCTree
Asked Answered
P

3

11

How can i fix 'java: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid'' error?

When I research the problem, I encountered Java version and lombok version incompatibility problem. I use java 19 and lombok 1.18.20 version in my spring boot project. How can I fix this problem without using jdk21?

Photophobia answered 15/10, 2023 at 18:5 Comment(6)
Lombok 1.18.20 is a very old version. Upgrade to 1.18.30.Seriocomic
@Seriocomic is correct, I was using lombok artifact earlier version 1.18.24 and got this above OP question, simply followed his comment and replaced with 1.18.30 and that worked fine.Diphenylhydantoin
I have this same error, but it happens when I try to run JUnit tests in maven with jdk 21. The issue has to do with incompatible versions somwhere in the dependencies. Dropping the project's jdk back to jdk17 solves the issue for me.Shelton
Still facing the error although I've already updated lombok to 1.18.30Liar
make sure your project setting use java 19.Swetiana
Got this error with lombok version 1.18.20, updating with 1.18.22 didn't work but 1.18.30 worked.Nonproductive
P
12

This issue is only related to incompatibility between Project SDK, Spring Boot and Lombok versions. These two pairs of old and new versions work well together. Note to check the "Project Structure" to make sure the correct SDK is set for the project. Check out the screenshot below each sample for more clarity.

  • Old versions
    • JDK 1.8
    • Spring Boot 2.7.2
    • Lombok 1.18.20

compatible old versions

  • New versions
    • JDK 21
    • Spring Boot 3.2.4
    • Lombok 1.18.30 compatible new versions
Pirnot answered 2/4 at 13:16 Comment(1)
worked after I switched my java to 1.8. ThanksBrazee
N
2

Got this error with lombok version 1.18.20. mvn clean package was failed. Updating with 1.18.22 didn't work but 1.18.30 worked.

Nonproductive answered 29/5 at 15:5 Comment(0)
T
2

The error message is occurring due to the use of older versions of Spring Boot, Lombok, and JDK. After updating to the latest versions, you should be able to build successfully.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.3.0</version>
    <relativePath/> <!-- lookup parent from repository -->
 </parent>

 <properties>
    <java.version>21</java.version>
 </properties>

<dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.32</version>
</dependency>
Turmoil answered 16/6 at 8:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.