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).
Similar Posts:
- 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;
- Could not transfer artifact org.glassfish:javax.el:pom:3.0.1-b06-SNAPSHOT from/to jvnet-nexus-snapshots (https://maven.java.net/content/repositories/snapshots)
- [Solved] IDEA: JSP Could Not Use session Build-in Object
- Tomcat Startup Error: Server Tomcat v8.5 Server at localhost failed to start.
- Error during artifact deployment. See server log f
- Using idea and maven, there is an error: (4, 21) Java: there is no problem with the package javax.servlet
- Tomcat Deployed Applications Start Error: java.lang.ClassCastException: [XXX].filter.CharacterEncoding cannot be cast to jakarta.servlet.Filter