java.lang.LinkageError: loader constraint violation

使用MyEclipse部署出现的问题


java.lang.LinkageError: loader constraint violation 
是由于容器提供的包和web应用引入的包冲突引起的。 
通过maven排除重复引用后解决。具体参见以下指引:
 

 

(本人使用经验:

1. 将jsp-api-***.jar删除

2. servlet-api-***.jar可以不删除

)


your application has a JAR file, which is already part the JVM or Servlet Container, in it's WEB-INF/lib folder (or WAR file) 
and the version of the JAR files is different to that of the JVM or Servlet Container 
JAR files you should never include in your web-app 
As a rule, the following jar files should never be part of your webapp: 

  • j2ee.jar - interfaces are implemented by Tomcat
  • jasper-*.jar - causes Exceptions, or will do when version of Tomcat is upgraded
  • jboss.jar - part of jboss - should not be part of your app
  • jsp-api.jar - causes Exceptions, or will do when version of Tomcat is upgraded
  • gwt-user.jar - contains javax.servlet.Servlet, so gets ignored by Tomcat
  • gwt-dev-linux.jar - contains javax.servlet.Servlet, so gets ignored by Tomcat
  • gwt-dev-windows.jar - contains javax.servlet.Servlet, so gets ignored by Tomcat
  • rt.jar - not sure why you would, but some have...
  • servlet-api.jar - this is really old too, switch to compiling with j2ee.jar
  • servlet.jar - this is really old too, switch to compiling with j2ee.jar
  • tools.jar - part of VM

You may require these for compiling your app (notably servlet-api.jar or j2ee.jar), but they should not be deployed as part of your webapp. 

jsp-api.jar and/or jasper-*.jar 
Including these files will cause the following exceptions: 

javax.servlet.ServletException: loader constraint violation: when resolving method "org.apache.jasper.compiler.JspRuntimeContext... 
java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.jasper.compiler.JspRuntimeContext... 
If these aren't thrown when deploying your app, they most likely will be when the version of Tomcat is next updated. By chance, you might be using exactly the same version as the container. They already exist in the container though, so remove them to save yourself future pain. 

servlet-api.jar - the most common mistakenly included JAR 
Many developers incorrectly include servlet-api.jar in their WEB-INF/lib folder. This no longer causes an exception because Tomcat and other app servers will recognize it as a problem when deploying the JAR file. However, it does cause the container to ignore any JAR file that contains the javax/servlet/Servlet.class. In this case, you will see the following warning in the system log: 
INFO: validateJarFile(/path/app/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值