Bug 52245

Summary: Add detection of EL Jar to WebappClassLoader
Product: Tomcat 7 Reporter: Pid <bugzilla>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: trunk   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Simple EL API test case
Patch to detect classes in javax.el and avoid loading repository/class

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.