Bug 52245 - Add detection of EL Jar to WebappClassLoader
Summary: Add detection of EL Jar to WebappClassLoader
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: trunk
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-25 15:13 UTC by Pid
Modified: 2012-01-12 19:49 UTC (History)
0 users



Attachments
Simple EL API test case (40.27 KB, application/octet-stream)
2011-11-25 18:00 UTC, Pid
Details
Patch to detect classes in javax.el and avoid loading repository/class (882 bytes, patch)
2011-11-25 18:37 UTC, Pid
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pid 2011-11-25 15:13:41 UTC
The EL API is not currently detected by the code in WebappClassLoader.
Applications containing el-api.jar will not start.

(patch to follow).
Comment 1 Konstantin Kolinko 2011-11-25 16:02:52 UTC
Can you explain what do you mean by this?
What is the actual behaviour and what is expected?
Comment 2 Pid 2011-11-25 17:58:36 UTC
(In reply to comment #1)
> Can you explain what do you mean by this?

(Sorry, I wanted to put an initial report in so I wouldn't forget.)

WebappClassLoader detects classes in certain packages/JARs (e.g. java.servlet.*) that are supplied by the container and won't load them, as per SRV.9.7.2.

> What is the actual behaviour and what is expected?

A simple application is attached. It will start, (my mistake earlier), but throws an exception when a JSP is accessed. The application contains el-api.jar in WEB-INF/lib.

The exception is:

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/index_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
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:342)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause:

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/index_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
	org.apache.jsp.index_jsp._jspInit(index_jsp.java:31)
	org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:181)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


The javax.el package is not detected by WebappClassLoader, unlike the javax.servlet package - which causes JARs to be ignored by the class loader.

SRV 9.7.2 suggests that classes discovered in the application classpath, but from the javax.el * packages should not be loaded by the WebappClassLoader as they are provided by the container.


* and possibly javax.annotation and javax.persistence, if the annotation-api.jar contains all of the classes, as opposed to a subset.
Comment 3 Pid 2011-11-25 18:00:13 UTC
Created attachment 27986 [details]
Simple EL API test case
Comment 4 Pid 2011-11-25 18:37:27 UTC
Created attachment 27987 [details]
Patch to detect classes in javax.el and avoid loading repository/class
Comment 5 Mark Thomas 2012-01-12 19:49:45 UTC
Thanks for the patch. Applied to trunk and 7.0.x and will be included in 7.0.24 onwards.