I updated tomcat-embed-core 11.0.2 to 11.0.3 - after that i am getting below issue. and spring boot applicaiton is not coming up.
am using JDK 17.0.8.0.7-1.win.x86_64 and spring-boot-starter-parent - 3.4.2 Please let me know how to fix the same.
org.springframework.context.ApplicationContextException: Unable to start web server
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:621)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)
at com.scb.cccf.Application.main(Application.java:21)
Caused by: java.lang.ExceptionInInitializerError: null
at org.apache.catalina.startup.Tomcat.<clinit>(Tomcat.java:1192)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:203)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
... 8 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field static final boolean java.io.FileSystem.useCanonCaches accessible: module java.base does not "opens java.io" to unnamed module @15bb6bea
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at org.apache.tomcat.util.compat.JreCompat.<clinit>(JreCompat.java:87)
... 12 common frames omitted ```
I have updated to 10.1.36 via upgrading spring boot to 3.4.3 and experience the same issue using JDK 17.
The error is:
JreCompat:175 - Failed to set the java.io.FileSystem.useCanonCaches static field
java.lang.IllegalAccessException: class org.apache.tomcat.util.compat.JreCompat cannot access a member of class java.io.FileSystem (in module java.base) with modifiers "static final"
And also later:
Caused by: java.lang.IllegalStateException: Unable to disable the global canonical file name cache or confirm that it is disabled when starting the WebResourceSet at [xxxx\src\main\webapp] which is part of the web application [/myapplication]. The WebResourceSet may be exposed to CVE-2024-56337.
at org.apache.catalina.webresources.DirResourceSet.initInternal(DirResourceSet.java:364)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:122)
The error goes away when adding --add-opens=java.base/java.io=ALL-UNNAMED OR updating to JDK 21.
I also experience the same error with some older projects still using Spring boot 2.7.18 and trying to upgrade to tomcat 9.0.100, also using JDK 17 - I guess the same fix was applied to 9.0.x.
Unfortunately I am not currently in a position to just update to JDK 21 and adding the runtime option to every project is also not an option.
One additional note: this testing was performed on Windows OS. I see some code in tomcat that suggests a case-sensitive filesystem won't throw this error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With