IllegalStateException: [..] is not a jakarta.servlet.Filter



  • Linux/Ubuntu20.04LTS
  • IntelliJ IDEA Community Editon 2021.1
  • maven 4.0.0
  • jetty-11.0.5


java.lang.IllegalStateException: class org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter is not a jakarta.servlet.Filter

Using the MVN jetty: run plug-in to run the web application, an exception occurred!

Servlet class org.restlet.ext.servlet.serverservlet is not a jakarta.servlet.servlet


Jakarta.servlet.servlet is part of servlet API version 5.0, and servlet API version 5.0 is part of Jakarta EE version 9. This only means that the servlet class specified in […] is not compiled for servlet API version 5.0, but for older versions

The technical reason is that in the steps from Java / Jakarta EE 8 to Jakarta EE 9, all javaxThe packages were renamed JakartaSoftware package. Therefore, backward compatibility no longer exists since Jakarta EE 9

When we translate the above facts into your specific situation, your only choice is to downgrade the jetty servlet container to servlet 4.0 compatible version. This is because the third-party library “restlet” is assigned to a third party. There is no servlet 5.0 compatible version at present. According to Jetty’s version table, jetty 11. X is the target of Jakarta EE 9, so you need jetty 10. X or earlier

Alternatively, you can drop restlet completely and use Jersey instead. At present, it has a version compatible with Jakarta EE 9

  • Upgrade the servlet class specified in […] to one compatible with servlet API version 5.0
  • Alternatively, downgrade the servlet container from servlet API version 5.0 to a previous version, at least matching the target servlet API version of the servlet class specified in […]


  1. Replace the lower version of jetty and directly modify the version of jetty in the configuration pom.xml file. Here, the version of 9. X is used
<!-- -->



Just run the project again

reference resources


  • [in rainy season, eat rainbow] – layuji
  • It is compiled and released by individuals. It is inevitable that there are omissions or errors in the compilation process. Please point out them so as not to mislead everyone!