Mantis - Resin
Viewing Issue Advanced Details
4248 minor always 10-07-10 14:52 11-10-10 09:59
closed 4.0.10  
none 4.0.14  
0004248: wrong classloader in forwarded webapp
(rep by jessicay on forums)


I am upgrading from resin 3.2.1 to resin 4.0.10, and noticed some unexpected behaviour change about session attribute in request forwarding.

I was trying to do this:

1. There are webapp_a and webapp_b
2. Request is forwarded from webapp_a to webapp_b
3. In webapp_b,
the request is first processed by TestServlet, then the code does the following to add a sessionAttribute and forward to an hello.jsp page located under webapp_b
SomeObj obj = new SomeObj(); // SomeObj does not implement
HttpSession session = request.getSession();
session.setAttribute("", obj);
this.getServletContext().getRequestDispatcher("/hello.jsp").forward(request, response);
in hello.jsp, we retrive the object from the session attribute and do some further processing.
SomeObj sObj = (SomeObj)session.getAttribute(" ");

resin 3.2.1 works fine, whereas resin 4.0.10 throws ClassCastException when the the request is forwarded although the class type is correct and the object is original.
I think this is related to ClassLoader.

To find out, I printed out the ClassLoader used in hello.jsp and found:
resin 3.2.1 used (DynamicClassLoader[SimpleLoader[C:/resin-3.2.1/webapps/webapp_b/WEB-INF/work]])
resin 4.0.10 used (DynamicClassLoader[SimpleLoader[C:/resin-4.0.10/webapps/webapp_a/WEB-INF/work]])

Please note the ClassLoader difference in resin 3.2.1 and resin 4.0.10, resin 4.0.10 ClassLoader has webapp_a although it is in webapp_b.
Once I made SomeObj implements, resin 4.0.10 would work, however, this should not be needed as the session attribute object is retrieved within the same webapp.

BTW, this is a single server environment on windows. What else can I do to make resin 4.0.10 behaves the same way as resin 3.2.1 regarding this issue?


in step 2, I did:

//forwarding request
RequestDispatcher rd = servletContext.getContext("/webapp_b").getRequestDispatcher("/servlet/TestServlet");
rd.forward(request, response);

11-08-10 11:15   
We're seeing this issue as well.
11-10-10 09:59