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
分享到:
相关推荐
NULL 博文链接:https://utopialxw.iteye.com/blog/1138133
java.lang.LinkageError 链接错误。该错误及其所有子类指示某个类依赖于另外一些类,在该类编译之后,被依赖的类改变了其类定义而没有重新编译所有的类,进而引发错误的情况。 java.lang.NoClassDefFoundError 未...
el-api,java jar包,el表达式所需要的jar包。java.lang.LinkageError: loader constraints violated when linking javax/el/ExpressionFactory class;jar包冲突
启动Tomcat时报错:Caused by: java.lang.LinkageError: loader constraints violated when linking javax/el/ExpressionFactory class 说明:原因是juel.jar, juel-engine.jar, juel-impl.jar包和Tomcat6.0中的el-...
Burpsuite永久使用版,没有使用限制,V1.7.26版本,http抓包工具。
java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file://build/web/WEB-INF/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class...
javax.servlet.ServletException: java.lang.LinkageError
MiMa可以报告二进制修改,这些修改可能导致JVM在运行时抛出java.lang.LinkageError (或其子类型之一,例如AbstractMethodError )。 链接错误通常是类/成员签名修改的结果。 MiMa比较了两个已发布库的所有类文件,...
下载本包解压后放在%TOMCAT_HOME%和%JAVA_HOME%\lib下(jar包必须在endorsed 文件夹下)
日常使用 Java 开发,常常会遇到包依赖冲突的问题,尤其当工程应用变得臃肿庞大,包冲突的问题也会变得更加棘手,导致各种各样的报错,例如LinkageError, NoSuchMethodError等;实际开发中,可以采用多种方法来解决...
SOFAArk 最初的场景是解决 Java 开发常常会遇到的包依赖冲突的问题,尤其当工程应用变得臃肿庞大,包冲突的问题也会变得更加棘手,导致各种各样的报错,例如LinkageError, NoSuchMethodError等。实际开发中,可以...
背景日常使用 Java 开发,常常会遇到包依赖冲突的问题,尤其当工程应用变得臃肿庞大,包冲突的问题也会变得更加棘手,导致各种各样的报错,例如LinkageError, NoSuchMethodError等;实际开发中,可以采用多种方法来...