tomcat项目报错org.apache.jasper.JasperException: java.lang.NullPointerException
现象:
访问tomcat项目报错,查看tomcat日志有报错
Sep 12, 2024 5:15:59 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception
java.lang.NullPointerException
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:371)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
原因:
项目依赖的jar包和tomcat容器的依赖jar包有重复,一般为servlet-api.jar、jsp-api.jar
解决方式:
如果是非maven项目,在/WEB-INF/lib中找出servlet-api.jar、jsp-api.jar删除
如果是maven项目就把pom.xml中的servlet依赖注释掉
注释掉重新打包发布