I'm running Jetty 12.0.15 with Spring Boot 3.2.12. My code is all Jakarta namespace and I'm using Jakarta Servlet 6.0.0 which is now supported. All my config works fine when I run the app from Eclipse with embedded Jetty. However when I start the app from a normal standalone Jetty server, I get class not found for javax.servlet.ServletContext
as follows.
Caused by:
java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at org.eclipse.jetty.ee10.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:494)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:320)
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:149)
at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:413)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:336)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:246)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:534)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:321)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:246)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:197)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:165)
...
I'm not including any of the Jetty artifacts in my WAR. I know that can cause problems. And I'm including all ee10 Jakarta versions of the jetty modules for the server and not the others when using start.jar --add-modules
.
Anybody have any ideas why it's generating this exception? I don't know what dependency is resolving incorrectly. Are incorrect Jetty modules causing this? If so, which Jetty modules should I be including?
Nevermind. The issue was related to a transient dependency that was including a version of the artifact that was not Jakarta compliant which was causing the issue.