Reputation: 29
I am upgrading an old Java 11 webapp to Java 17 and Tomcat 10.
After upgrading all the code, exchanging javax.servlet to jakarta.servlet, and adjusting the code accordingly for some methods, everything compiles, but I cannot deploy the app to Tomcat 10. I get the following error:
SEVERE [Catalina-utility-2] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [SecurityFilter]
java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
The security filter is defined in web.xml, like this:
<filter>
<filter-name>SecurityFilter</filter-name>
<filter-class>waffle.servlet.NegotiateSecurityFilter</filter-class>
<init-param>
<param-name>waffle.servlet.spi.NegotiateSecurityFilterProvider/protocols</param-name>
<param-value>NTLM</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
thus depends on waffle. Now, there is no dependency on waffle in the pom.xml directly, but I identified that a dependency (an internal commons-library) had in turn a waffle dependency. I checked that pom, and it referred to waffle 1.5. I changed that into waffle 3.5.0:
<dependency>
<groupId>com.github.waffle</groupId>
<artifactId>waffle-jna</artifactId>
<version>3.5.0</version>
</dependency>
I recompiled a new version of this common-library, I changed the dependency in my webapp to depend on this new version, recompiled the webapp, but I still get exactly the same error.
If I comment the Security Filter in web.xml, the webapp starts, so it's clearly the waffle security filter that causes the error. But what on earth in waffle 3.5.0 could still depend on javax.servlet?
I have tried as much as I can, but am rather unexperienced in these fields, so I am stumped.
Upvotes: 0
Views: 23
Reputation: 29
Sometimes, it seems, one needs to spend time to ask the question in order to find the answer themselves...
I tried a final search, and it seems that, even though Waffle 3.5.0 is from very recently, it is not upgraded to work with Java 17. Instead, there is a separate depencency called "waffle-jna-jakarta" that works with jakarta instead.
I guess the regular Waffle for javax.servlet is still updated for posterity.
<dependency>
<groupId>com.github.waffle</groupId>
<artifactId>waffle-jna-jakarta</artifactId>
<version>3.0.0</version>
</dependency>
was the answer.
Upvotes: 1