remm 01/08/07 17:32:02
Modified: catalina/src/share/org/apache/catalina/core
ApplicationDispatcher.java
Log:
- Cross contexts include and forwards were broken because the context
class loader wasn't appropriately set. Now, check if the current context class
loader is the same as the one in the Catalina Context's loader. If it's not, the
old context class loader value is saved, the Catalina Context class loader is
set as the context class loader, and after the wrapper has been allocated
and invoked, the old context class loader value is restored.
Bug reported by Serge Huber <shuber at xo3.com>.
Revision Changes Path
1.25 +20 -5
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
Index: ApplicationDispatcher.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ApplicationDispatcher.java 2001/08/01 03:04:04 1.24
+++ ApplicationDispatcher.java 2001/08/08 00:31:54 1.25
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v
1.24 2001/08/01 03:04:04 craigmcc Exp $
- * $Revision: 1.24 $
- * $Date: 2001/08/01 03:04:04 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v
1.25 2001/08/08 00:31:54 remm Exp $
+ * $Revision: 1.25 $
+ * $Date: 2001/08/08 00:31:54 $
*
* ====================================================================
*
@@ -108,7 +108,7 @@
* <code>javax.servlet.ServletResponseWrapper</code>.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.24 $ $Date: 2001/08/01 03:04:04 $
+ * @version $Revision: 1.25 $ $Date: 2001/08/08 00:31:54 $
*/
final class ApplicationDispatcher
@@ -337,7 +337,6 @@
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
-
public void forward(ServletRequest request, ServletResponse response)
throws ServletException, IOException
{
@@ -591,6 +590,18 @@
private void invoke(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
+ // Checking to see if the context classloader is the current context
+ // classloader. If it's not, we're saving it, and setting the context
+ // classloader to the Context classloader
+ ClassLoader oldCCL = Thread.currentThread().getContextClassLoader();
+ ClassLoader contextClassLoader = context.getLoader().getClassLoader();
+
+ if (oldCCL != contextClassLoader) {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ } else {
+ oldCCL = null;
+ }
+
// Initialize local variables we may need
HttpServletRequest hrequest = null;
if (request instanceof HttpServletRequest)
@@ -716,6 +727,10 @@
(sm.getString("applicationDispatcher.deallocateException",
wrapper.getName()), e);
}
+
+ // Reset the old context class loader
+ if (oldCCL != null)
+ Thread.currentThread().setContextClassLoader(oldCCL);
// Rethrow an exception if one was thrown by the invoked servlet
if (ioException != null)