Summary: | Add detection of EL Jar to WebappClassLoader | ||
---|---|---|---|
Product: | Tomcat 7 | Reporter: | Pid <bugzilla> |
Component: | Catalina | Assignee: | 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
Can you explain what do you mean by this? What is the actual behaviour and what is expected? (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. Created attachment 27986 [details]
Simple EL API test case
Created attachment 27987 [details]
Patch to detect classes in javax.el and avoid loading repository/class
Thanks for the patch. Applied to trunk and 7.0.x and will be included in 7.0.24 onwards. |