首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

java.lang.LinkageError: loader constraint violation的异常

2012-12-20 
java.lang.LinkageError: loader constraint violation的错误java.lang.LinkageError: loader constraint

java.lang.LinkageError: loader constraint violation的错误

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

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

热点排行