1

My service is deployed on tomcat. Recently we upgraded the tomcat to 9.0.43. And when the service is restarted (tomcat is installed on windows as a service), it throws the following error:

SEVERE [Thread-19] org.apache.catalina.core.ApplicationFilterConfig.release Failed to destroy the filter named [Tomcat WebSocket (JSR356) Filter] of type [org.apache.tomcat.websocket.server.WsFilter]
    java.lang.AbstractMethodError: Receiver class org.apache.tomcat.websocket.server.WsFilter does not define or inherit an implementation of the resolved method abstract destroy()V of interface javax.servlet.Filter.
        at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:301)

I looked into and find the root cause. Earlier there was a destroy method implementation in tomcat-websocket.jar in the WsFilter.class under lib\tomcat-websocket\org\apache\tomcat\websocket\server\WsFilter.class, which is now missing.

How shall I proceed now? Any ideas?

Coffee_lover
  • 545
  • 6
  • 15

1 Answers1

3

Since Servlet 4.0 API the init and close methods of the Filter interface have default implementations. Check if you are not deploying another (and older) javax.servlet-api.jar with your application.

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43
  • Thanks a lot. Let me check my project and get back. – Coffee_lover Feb 25 '21 at 08:46
  • I couldn't find anything. The libraries only contains the tomcat 9.0.41 libs. – Coffee_lover Feb 25 '21 at 09:30
  • 1
    There should be a `javax.servlet.Filter` in `$CATALINA_BASE/lib/servlet-api.jar`, while the `WEB-INF/lib` folder of each application should not contain any JAR containing that class. – Piotr P. Karwasz Feb 25 '21 at 10:40
  • Nope there are only 2 jars deployed under WEB-INF/lib – Coffee_lover Feb 25 '21 at 11:08
  • Some libraries like to include files that don't belong to them. I would check with `zip -t` at this point. The old `javax.servlet.Filter` class must be loaded from somewhere, most probably the web application classloader. – Piotr P. Karwasz Feb 25 '21 at 11:20
  • 1
    I got it . There is a servlet api in another folder but seems like it is being picked up. Thanks a lot for the answer. I will mark is as answer. I will check for the classpath issue. – Coffee_lover Feb 25 '21 at 11:23
  • 1
    Maybe you have a [CATALINA_BASE/CATALINA_HOME](https://tomcat.apache.org/tomcat-9.0-doc/introduction.html#CATALINA_HOME_and_CATALINA_BASE) configuration. Look into `catalina.properties` to see the classpath's of all Tomcat classloaders. – Piotr P. Karwasz Feb 25 '21 at 11:40
  • https://stackoverflow.com/questions/66480830/tomcat-picking-up-servlet-api-jar-from-shared-folder-instead-of-tomcat-lib-folde – Coffee_lover Mar 04 '21 at 18:21
  • Can you please check this question as well? – Coffee_lover Mar 04 '21 at 18:21