spring-framework: Illegal reflective access operation on Java 11 for lazy-init beans registered with MBeanServer
I’m using spring-boot 2.2.0.M2 with Java 11 and i am getting this warning:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/home/porfirio/.m2/repository/org/springframework/spring-core/5.2.0.M1/spring-core-5.2.0.M1.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I don’t know if it is a know bug with spring-boot+java11 or an issue on my end
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 44 (8 by maintainers)
I have the same problem, so here is my small contribution…
I use JDK 11 / Spring Boot 2.2.1
The message appears only if I add Dev Tools dependency. Without Dev Tools, no message. Adding
--add-opens java.base/java.lang=ALL-UNNAMEDto thespring-boot.run.jvmArgumentsmade the message disappear.#Solved I have got the same warning and I googled it for 12 hours tried all possible codes and dependencies. actually the application will still run and without adding any code just make sure you call your application properly from the localhost to do so look at the application property and check this server.contextPath=/myapi localhost:8080/myapi
Hi,
I have been monitoring this issue for a few months as I am experiencing the exact same issue.
When I use Spring Boot 2.1.3.RELEASE with Java 11, then I do not get this WARNING.
When I move to Spring Boot 2.1.4.RELEASE, 2.1.5.RELEASE, 2.1.6.RELEASE and 2.1.7.RELEASE I get the warning.
I am not sure why we did not get this warning on 2.1.3.RELEASE. Maybe it was fixed and there has been a code regression. Or maybe the issue is present on 2.1.3.RELEASE but the WARNING is just not being logged.
Updating to the latest spring boot 2.2.4 (with spring 5.2.3) did not change much:
Similar Issue on Spring Boot 2.2.0.RELEASE, Spring Cloud Gateway 2.2.0.M3 (Spring Cloud Version: Hoxton.M3)
I’m surprised that no ticket existed before 3 days ago. The original problem dates back almost 2 years ago and its pretty much existed since then.
Use 1.8 (Java 8) Or define the version in pom.xml
I have resolved it by downgrading java version to 1.8
If it helps then I have it too (Java 11 / Spring Boot 2.2.3):
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/C:/Users/cors/.m2/repository/org/springframework/spring-core/5.2.3.RELEASE/spring-core-5.2.3.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
@Isabek, according to the comments from @jhoeller in https://github.com/spring-projects/spring-framework/issues/22674#issuecomment-476607240, “those warnings will only disappear as of Spring Framework 5.1+”.
So, if you are seeing them with
5.0.11.RELEASE, that’s to be expected, and you should be able to ignore them for the time being.Can you confirm that you do not see them on Spring Framework 5.1+?
@iamprashant sorry, but that is not a solution, I need Java 11 features and Java 11 is an LTS version, it should be supported
Depends on your Java env
Then make sure you have
Same issue on Spring Boot 2.2.0.RC1 + Spring Framework 5.2.0 with JDK 11.
@iamprashant what have you provided that is a solution to this specific issue? specifying the JDK version in the compiler plugin is not a solution
@LifeIsStrange here’s the reference to the issue you’ve created in Spring Boot: https://github.com/spring-projects/spring-boot/issues/24857
Same here with Spring Boot 2.2.2
As noted by @Maze-fr I confirm that removing org.springframework.boot:spring-boot-devtools removes the warning.
I seem to be getting this specifically when I using the
@targetpointcut expression (with Java 11 or 13, and Spring Boot 2.2.1).Also getting this on Boot 2.2.0.M6 with JDK 12. Seems to be a slightly different stack trace than the ones posted above:
Very similar issue on my end, started showing up after upgrading to Boot 2.1.5 and Java 11. Not sure if the stack trace is teh same, so I’ll paste it just in case.
@porfirioribeiro, thanks for providing the stack trace. I have updated this issue’s title accordingly.