It turns out that there is a problem with the matching between the versions of Servlet, JSP and Spring. As we all know, in 2018, Java EE was renamed Jakarta EE. This resulted in the package names of some JAR packages being changed in later versions. The impact of this on this project is that Spring itself does not contain Servlet and JSP JAR packages, but it relies on these JAR packages. If the project deployed in the Tomcat server uses Spring, this part of the JAR package will be provided by the Tomcat server. The problem is that the JAR package prefix expected by Spring 5.2.9.RELEASE is javax, while the JAR package prefix provided by Tomcat 10.0.0 is jakarta. Therefore, Spring reported an error that there is no JAR package for Servlet or JSP.
(The URL for viewing the Servlet and other versions corresponding to each version of Tomcat is: http://tomcat.apache.org/whichversion.html)
Since Tomcat is closely related to the JAR packages of Servlet and JSP, it cannot be solved by replacing the JAR packages of Servlet and JSP in the folder lib under Tomcat. Moreover, this cannot be solved by adding the correct Servlet and JSP dependencies in Maven. In fact, if the pure Java code part of the project does not use the JAR packages of Servlet and JSP, in fact, the Servlet and JSP dependencies added in Maven are here. Can be deleted. (In a more professional way, in Maven-based Web applications, the scope of dependency on Servlet and JSP is provided.)
Fortunately, the JAR package prefix used by Tomcat 9.0.41 is javax. Therefore, you only need to install another Tomcat 9.0.41 here (the existing Tomcat does not need to be uninstalled, because the installation path of different versions of Tomcat can be different, but the existing Tomcat server needs to be shut down during installation to avoid occupying the same A port number).
- Springboot always reports an error when importing JSP dependencies
- HTTP Status 500 – Unable to compile class for JSP settlement program
- Maven does not have a servlet (an error is reported after the servlet is created)
- import javax.servlet.http.HttpSession;
- Tomcat Startup Error: Server Tomcat v8.5 Server at localhost failed to start.
- Error during artifact deployment. See server log f
- The following table: unable to import javax. Servlet. HttpServletRequest
- [How to Solve] java.lang.IncompatibleClassChangeError
- [Solved] Eclipse Error: java.lang.ClassNotFoundException: ContextLoaderListener
- [How to Solve] SEVERE: Error configuring application listener of