20

I encountered the problem of having the same .jar (for my case, el-api.jar v2.1)twice for one project, hence, the following error stack when I try to run my project using 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

I have found the http://blog.springsource.com/2008/10/20/understanding-the-osgi-uses-directive/

but that is not useful as the solution effects too many parts of my project.

I can't make any changes to the Tomcat as well as the project will be used by many other user.

The current work around is to manuelly delete the el-api.jar every time we do a build AND uses Tomcat6. Then we need to put the .jar back as that is requested for other stuff.

I am used Maven 2 and Maven 3 to build. (btw, did anyone know about use Maven3 on Jruby?)

Can anyone help me with the issue?

guerda
  • 23,388
  • 27
  • 97
  • 146
  • Sorry for the ambiguity, to solve the problem, the I think it require a way to make sure Tomcat 6 pick up only one el-api.jar not both of them. The constraint will be: - No change to Tomcat 6 - One releases - The solution can be continuously integrated in the build –  Sep 21 '10 at 15:35

2 Answers2

18

I encountered the problem of having the same .jar (for my case, el-api.jar v2.1)twice for one project, hence, the following error stack when I try to run my project using Tomcat 6.

Then mark the el-api.jar artifact as provided, if it is.

The current work around is to manuelly delete the el-api.jar every time we do a build AND uses Tomcat6. Then we need to put the .jar back as that is requested for other stuff.

A much better way to handle this would be to declare the dependency inside profiles and to mark it as provided (e.g. in a "tomcat6" profile) or not depending on the needs.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Thanks for the answer, but that wouldn't work for our case because by having two profile, we need two releases and I wanted only one. –  Sep 21 '10 at 14:51
  • @Javabeginner I don't see how manually deleting/adding files is better... What are you looking for *exactly*? What are your constraints? What are your requirements? Adding details usually help to get answers matching them. – Pascal Thivent Sep 21 '10 at 15:07
  • Sorry for the ambiguity, to solve the problem, the I think it require a way to make sure Tomcat 6 pick up only one el-api.jar not both of them. The constraint will be: - No change to Tomcat 6 - One releases - The solution can be continuously integrated in the build –  Sep 21 '10 at 15:35
  • @Javabeginner isn't the "other" el-api.jar bundled inside the Tomcat 6 lib directory? I'm afraid the right way to handle this is to not package it in your war is it's already provided. – Pascal Thivent Sep 22 '10 at 01:13
  • Sorry, that "other" el-api.jar is required by other parts of the build. so the el-api.jar needed to be there incase someone wanted to use other application server instead of Tomcat6. I am thinking that if I change the name of the "other" el-api.jar, would that solve the problem? –  Sep 22 '10 at 08:15
  • @Javabeginner Which is why I believe you'll *have to* create two versions of your WAR. And no, renaming it won't solve anything. – Pascal Thivent Sep 22 '10 at 13:04
  • If one uses Eclipse for Maven WTP developent: m2e-wtp will handle provided dependencies correctly when deploying to Eclipse integrated servers (http://stackoverflow.com/questions/6979513/eclipse-wtp-maven-and-m2eclipse-not-copying-provided-jars). – Eduard Wirch Aug 30 '12 at 08:15
6

I got this error attempting to run the Spring (3.0.5) sample mvc-ajax with Tomcat 7.

Tomcat 7 uses el-api 2.2 and jsp-api 2.2. The mvc-ajax pom file specifies jsp-api 2.1, which also contains the classes in el-api.

To get this running I commented out jsp-api 2.1 from the pom. This allowed Tomcat to use its own (more recent) version.

Jim Sime
  • 131
  • 2
  • 1