加载器约束违规

20 java continuous-integration maven-2

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

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
Run Code Online (Sandbox Code Playgroud)

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

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

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

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

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

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

Pas*_*ent 17

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

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

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

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


小智 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使用自己的(更新的)版本.