DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38673>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38673

           Summary: The Web Application classloader does not work as stated
                    in the documentation
           Product: Tomcat 5
           Version: 5.5.14
          Platform: All
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


The documentation says that the Web Application classloader delegates the 
loading of classes in the javax.* packages to its parent first. Furthermore, 
it is said that "any JAR containing Servlet API classes will be ignored by the 
[Web Application] classloader". Neither statements are true in practice.

The problem can be easily reproduced:
1) Create a Web application with a JAR file containing a different version of 
the JSP specifications classes then the one Tomcat uses;
2) Explicitely load a class from the javax.servlet.jsp.* package inside the 
contextInitialized method of a ServletContextListener using the Web 
Application classloader and its parent;
3) Compare the classes that are returned.

An example is shown below.

// This returns the Web Application ClassLoader (the one used
// to load the implementation of the ServletContextListener
// interface).
ClassLoader web = getClass().getClassLoader();

// This returns the parent ClassLoader to which loading classes
// from the javax.* package should be delegated.
ClassLoader parent = web.getParent();

// Both classes should be the same since web should delegate its
// loading to parent.
Class c1 = web.loadClass("javax.servlet.jsp.el.ELException");
Class c2 = web.loadClass("javax.servlet.jsp.el.ELException");
System.out.println(c1 == c2 ? "As expected!" : "BUG!");

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to