`
somebody_hjh
  • 浏览: 182339 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

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

    博客分类:
  • Java
阅读更多
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
2
0
分享到:
评论

相关推荐

    Exception in thread \"main\" java.lang.LinkageError错误的解决

    NULL 博文链接:https://utopialxw.iteye.com/blog/1138133

    java.lang.NoClassDefFoundError错误解决办法

    "java.lang.NoClassDefFoundError错误解决办法" java.lang.NoClassDefFoundError错误是一种常见的Java错误,它发生在Java虚拟机在编译时能找到合适的类,而在运行时不能找到合适的类导致的错误。下面是该错误的解决...

    在Java中异常分析

    - **异常路径**:`java.lang.Object -> java.lang.Throwable -> java.lang.Error -> java.lang.LinkageError -> java.lang.IncompatibleClassChangeError` - **解释**:当类文件中的类型与预期类型不匹配时抛出。 - ...

    juel-Tomcat与EL冲突问题

    启动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-...

    JBPM4运行时错误异常总结

    3. `javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation`: 这个错误是由于两个不同的类加载器加载了同一个类的不同版本,导致签名冲突。解决方法是统一项目和Tomcat服务器中的库...

    java 异常种类总结【转】.docx

    java.lang.LinkageError 是一种链接错误,指的是在程序中某个类依赖于另外一些类,但是这些类的定义发生了变化时抛出的异常。 24. java.lang.NoClassDefFoundError 未找到类定义错误 java.lang....

    解决出现 java.lang.ExceptionInInitializerError错误问题

    `java.lang.ExceptionInInitializerError` 是Java编程语言中一种比较特殊的异常,通常在类的静态初始化过程中遇到问题时抛出。这个错误意味着在初始化类的静态变量或静态初始化块(static block)时发生了异常。这类...

    Burp suite主题插件.jar

    每个人都知道黑客只在晚上工作,所以多年来人们要求 PortSwigger 实现一个黑暗主题。当他们这样做时,黑客们到处欢欣鼓舞!但是,有些人仍然想要更多......直到...... Burp Customizer! Burp Suite 2020.12 用 ...

    el-api.jar

    el-api,java jar包,el表达式所需要的jar包。java.lang.LinkageError: loader constraints violated when linking javax/el/ExpressionFactory class;jar包冲突

    Burpsuite永久版

    Burpsuite永久使用版,没有使用限制,V1.7.26版本,http抓包工具。

    jaxb-2_1_9.zip

    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...

    常见java异常.txt

    - 类层次结构:java.lang.Object -> java.lang.Throwable -> java.lang.Error -> java.lang.LinkageError -> java.lang.IncompatibleClassChangeError - 描述:当类或接口的实现不符合其定义时,比如方法签名改变...

    java异常类型.txt

    5. **`java.lang.LinkageError`** - 与类加载有关的错误,例如无法解析类依赖时会抛出此类错误。 ### 总结 了解这些异常类型对于编写健壮可靠的Java应用程序至关重要。正确地处理异常不仅可以提高程序的稳定性,还...

    常见JAVA异常总结

    `java.lang.IncompatibleClassChangeError` 是一种链接错误,发生在类的静态类型与实际类型不兼容的情况下。例如,当一个方法期望一个接口类型的对象,但实际传入的是非接口实现类的对象时,就会抛出此异常。 - **...

    java所有运行时异常以及错误.

    Java编程语言在运行过程中可能会遇到各种异常和错误,这些异常和错误是程序运行不正常的表现,需要开发者进行处理或修复。这里我们将详细讨论Java中的运行时异常和错误。 首先,运行时异常是程序在执行过程中可以...

    endorsed 解决soa连接错误

    在Java中,如果不同库之间存在版本冲突,可能会导致`java.lang.LinkageError`,特别是涉及到Java API的更新时,如JAXB或JAX-WS。 描述中提到,将解压后的jar包放置在`%TOMCAT_HOME%`和`%JAVA_HOME%\lib\endorsed`...

    JAVA讲义第6章.pdf

    文件片段还提到了一些Java的核心类库,如`java.lang.Object`、`java.lang.Throwable`、`java.lang.Exception`、`java.lang.RuntimeException`、`java.lang.Non_RuntimeException`等。这里提到了Java的基本类型层次...

    juel-impl.jar

    javax.servlet.ServletException: java.lang.LinkageError

Global site tag (gtag.js) - Google Analytics