加载器约束违规

时间:2010-09-21 14:21:40

标签: java maven-2 continuous-integration

我在一个项目中遇到了两次相同的.jar(对于我的情况,el-api.jar v2.1)两次的问题,因此,当我尝试使用Tomcat 6运行我的项目时出现以下错误堆栈。 / p>

WARNING: Unexpected error forwarding to login page
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/login_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature

 at java.lang.Thread.run(Thread.java:619)
Caused by: 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/login_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature

我找到了 http://blog.springsource.com/2008/10/20/understanding-the-osgi-uses-directive/

但这没有用,因为解决方案影响了我项目的太多部分。

我无法对Tomcat进行任何更改,并且该项目将被许多其他用户使用。

目前的工作是每次我们进行构建时使用Tomcat6来删除el-api.jar。然后我们需要将.jar放回到其他东西的请求。

我使用Maven 2和Maven 3来构建。 (顺便说一下,有没有人知道在Jruby上使用Maven3?)

任何人都可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:17)

  

我在一个项目中遇到了两次相同的.jar(对于我的情况,el-api.jar v2.1)两次的问题,因此,当我尝试使用Tomcat 6运行我的项目时出现以下错误堆栈。 / p>

然后将el-api.jar工件标记为provided,如果是的话。

  

目前的工作是每次我们进行构建时使用Tomcat6来删除el-api.jar。然后我们需要将.jar放回到其他东西的请求。

处理此问题的一种更好的方法是在配置文件中声明依赖关系并将其标记为provided(例如,在“tomcat6”配置文件中)或根据需要而不是。

答案 1 :(得分:6)

尝试使用Tomcat 7运行Spring(3.0.5)示例mvc-ajax时出现此错误。

Tomcat 7使用el-api 2.2和jsp-api 2.2。 mvc-ajax pom文件指定了jsp-api 2.1,它还包含el-api中的类。

为了让这个运行,我从pom中注释掉了jsp-api 2.1。这允许Tomcat使用自己的(更新的)版本。