Issue
I am trying to compile an existing Spring Boot project using JDK 17 and Maven 3.8.4 and I keep getting this error.
Unable to make field private com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors com.sun.tools.javac.processing.JavacProcessingEnvironment.discoveredProcs accessible: module jdk.compiler does not "opens com.sun.tools.javac.processing" to unnamed module @521e3470
The problem also occurs with older versions of Maven like 3.6. It also happens with JDK 16. It does not matter what version of Java is configured in the pom.xml via the java.version
, maven.compiler.source
, and maven.compiler.target
. only the JDK version being used to do the compiling... displayed in the mvn -v
command.
The project compiles fine using JDK 15. The error happens immediately when compiling starts, right after the INFO message stating how many classes are being compiled. Happens in both my Windows laptop and Ubuntu CI server.
Any ideas what this could be?
EDIT: adding more of the POM file.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>15</java.version>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<spring-cloud.version>2020.0.4</spring-cloud.version>
<ch.qos.logback.version>1.2.3</ch.qos.logback.version>
</properties>
EDIT: i also use Lombok
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
</dependency>
EDIT: I dont think this is the same question as the other one because I searched by error msg, and that other question never popped up in the results. To arrive to that question, you need to know that the error is related to Lombok. The error gives no clue to Lombok being the culprit.
Solution
The problem is the usage of lombok project which in this case being used not the most recent version.
Answered By - khmarbaise
Answer Checked By - David Goodson (JavaFixing Volunteer)