Problem description
Cause
since the author uses Tomcat 10, the servlet dependency used is Jakarta Servlet. For details, see building a servlet using Tomcat 10. An error is reported: class XXX is not a servlet. The error is because the servlet API package is not imported.
Solution:
Import servlet API dependencies.
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
Similar Posts:
- [Solved] Jsonobject has no from object, idea has no Maven dependency, jsonobject Maven dependency package
- Springboot always reports an error when importing JSP dependencies
- Error during artifact deployment. See server log f
- Maven does not have a servlet (an error is reported after the servlet is created)
- Springboot startup error start bean ‘eurekaautoserviceregistration’ NullPointerException
- [Solved] Tomcat10 Error: jakarta.servlet.ServletException: Class com.kuang.servlet.HelloServlet is not a servlet
- The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- [Solved] SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
- [Solved] JSTL1.2 Error: org.apache.catalina.core.StandardWrapperValve.invoke…
- [Solved] java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUni