作者:宝贝猪雯 | 来源:互联网 | 2023-10-15 12:41
浏览器运行项目异常如下:HTTPStatus500-typeExceptionreportmessagedescriptionTheserverencounteredaninter
浏览器运行项目异常如下:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type p.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory; used in the signature
org.apache.jsp.index_jsp._jspInit(index_jsp.java:31)
org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:181)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
刚看到该异常有点蒙,Ljavax/el/ExpressionFactory什么鬼,我的servlet-api.jar和jsp-api.jar都有啊
org.apache.tomcat
servlet-api
6.0.37
javax.servlet.jsp
jsp-api
2.1
通过网上的解释是tomcat1.7中的servlet-api.jar包,jsp-api.jar等与自己lib中的jar有所冲突
给的解决方案就是去掉自己项目中lib中冲突的jar包
但是问题又来了,那自己的是maven项目重启不就找不到相关jar包了吗,启动不就报错了吗
好吧,那我就设置包的作用范围为provided
org.apache.tomcat
servlet-api
6.0.37
provided
javax.servlet.jsp
jsp-api
2.1
provided
重新发布,启动tomcat,运行,成功,谢谢老天
PS_Maven_scope:
在POM 4中,中,它主要管理依赖的部署,目前可以使用5个值
* compile: 缺省值,适用于所有阶段,会随着项目一起发布
* provided: 类似compile,期望JDK、容器或使用者会提供这个依赖,如servlet.jar
* runtime: 只在运行时使用,如JDBC驱动,适用运行和测试阶段
* test: 只在测试时使用,用于编译和运行测试代码,不会随项目发布
* system: 类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它