Illegal reflective access when I stop SpringBoot web application with Tomcat 9 and Java10

点点圈 提交于 2021-01-26 21:36:01

问题


I'm trying Java 10 development with Spring Boot 2 and I encounter some issues.

The application is a simple webapp based upon Spring Boot 2. The application launch is ok but when I stop it, I get this warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.catalina.loader.WebappClassLoaderBase (file:/C:/Users/CS/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.11/tomcat-embed-core-9.0.11.jar) to field java.io.ObjectStreamClass$Caches.localDescs
WARNING: Please consider reporting this to the maintainers of org.apache.catalina.loader.WebappClassLoaderBase
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

As you see, I already switch the embeded Tomcat server from version 8 to 9.0.11 to be compliant with the Java module system. And the application is launched with the option --add-opens java.base/java.lang=ALL-UNNAMED

Does anybody know why I get this message ?


回答1:


To silence these warnings, you will need the following options in your startup script:

--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED

as you can see in the Tomcat 9 startup script.

The fixes for the warnings are not likely to be addressed anytime soon:

Are there plans to address these in a future release?

Not at the moment.

We'll keep the explicit clearing in place as long as we can. Once it is permanently blocked we'll probably have to rely on the fact that the Maps in question use a WeakReference and wait for GC to clear the references. That will make tracking down genuine memory leaks harder so we'll have to see if we can persuade the JRE team to provide some sort of replacement API if/when we reach that point.



来源:https://stackoverflow.com/questions/52185626/illegal-reflective-access-when-i-stop-springboot-web-application-with-tomcat-9-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!