Tomcat 加载 jsp 异常:ServletException: java.lang.LinkageError

环境:win10

JDK:java version "1.8.0_131"

mvn 内置 Tomcat 报错:

javax.servlet.ServletException: 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/WEB_002dINF/views/success_jsp, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm)
for the method's defining class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:)
javax.servlet.http.HttpServlet.service(HttpServlet.java:)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:)
javax.servlet.http.HttpServlet.service(HttpServlet.java:)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:)
javax.servlet.http.HttpServlet.service(HttpServlet.java:)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:)

原因:

Tomcat 包下的 javax.el-api 与 用于验证的 Hibernate-validation 包下的 javax.el-api 冲突。

解决:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0..CR2</version>
<exclusions>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
</exclusion>
</exclusions>
</dependency>
上一篇:ORACLE 11g 用Duplicate恢复Data Guard 备库详细过程


下一篇:关于Unicode,字符集,字符编码,每个程序员都应该知道的事