craigmcc 01/01/04 12:05:41
Modified: catalina/src/share/org/apache/catalina/core
ContainerBase.java
catalina/src/share/org/apache/catalina/startup Catalina.java
Log:
Ripple down configuration of the parent class loader when processing the
server.xml file. This is necessary due to timing considerations during
startup processing, and solves the "Class xxx is not a servlet" exception
when a sysadmin configures a <Loader> with non-default properties.
Revision Changes Path
1.6 +5 -4
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java
Index: ContainerBase.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ContainerBase.java 2000/11/03 00:21:15 1.5
+++ ContainerBase.java 2001/01/04 20:05:36 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
1.5 2000/11/03 00:21:15 craigmcc Exp $
- * $Revision: 1.5 $
- * $Date: 2000/11/03 00:21:15 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
1.6 2001/01/04 20:05:36 craigmcc Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/01/04 20:05:36 $
*
* ====================================================================
*
@@ -150,7 +150,7 @@
* class comments of the implementation class.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.5 $ $Date: 2000/11/03 00:21:15 $
+ * @version $Revision: 1.6 $ $Date: 2001/01/04 20:05:36 $
*/
public abstract class ContainerBase
@@ -1451,3 +1451,4 @@
}
+
1.11 +108 -16
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Catalina.java
Index: Catalina.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Catalina.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Catalina.java 2001/01/03 20:07:30 1.10
+++ Catalina.java 2001/01/04 20:05:39 1.11
@@ -1,13 +1,13 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Catalina.java,v
1.10 2001/01/03 20:07:30 craigmcc Exp $
- * $Revision: 1.10 $
- * $Date: 2001/01/03 20:07:30 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Catalina.java,v
1.11 2001/01/04 20:05:39 craigmcc Exp $
+ * $Revision: 1.11 $
+ * $Date: 2001/01/04 20:05:39 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.catalina.startup;
@@ -76,6 +76,7 @@
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
+import org.apache.catalina.loader.StandardLoader;
import org.apache.catalina.util.xml.SaxContext;
import org.apache.catalina.util.xml.XmlAction;
import org.apache.catalina.util.xml.XmlMapper;
@@ -95,7 +96,7 @@
* </u>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.10 $ $Date: 2001/01/03 20:07:30 $
+ * @version $Revision: 1.11 $ $Date: 2001/01/04 20:05:39 $
*/
public class Catalina {
@@ -330,6 +331,8 @@
("org.apache.catalina.core.StandardHost",
"className"));
mapper.addRule("Server/Service/Engine/Host", mapper.setProperties());
+ mapper.addRule("Server/Service/Engine/Host",
+ new CopyParentClassLoaderAction());
mapper.addRule("Server/Service/Engine/Host",
new LifecycleListenerAction
("org.apache.catalina.startup.HostConfig",
@@ -429,6 +432,8 @@
("org.apache.catalina.core.StandardContext",
"className"));
mapper.addRule(prefix + "", mapper.setProperties());
+ mapper.addRule(prefix + "",
+ new CopyParentClassLoaderAction());
mapper.addRule(prefix + "",
new LifecycleListenerAction
("org.apache.catalina.startup.ContextConfig",
@@ -441,7 +446,7 @@
mapper.addRule(prefix + "/ResourceParams",
mapper.setProperties());
mapper.addRule(prefix + "/ResourceParams", mapper.addChild
- ("addResourceParams",
+ ("addResourceParams",
"org.apache.catalina.deploy.ResourceParams"));
mapper.addRule(prefix + "/ResourceParams/parameter",
mapper.methodSetter("addParameter", 2));
@@ -479,10 +484,14 @@
("addLifecycleListener",
"org.apache.catalina.LifecycleListener"));
- mapper.addRule(prefix + "/Loader",
+ /*
+ mapper.addRule(prefix + "/Loader",
mapper.objectCreate
("org.apache.catalina.loader.StandardLoader",
"className"));
+ */
+ mapper.addRule(prefix + "/Loader",
+ new CreateLoaderAction());
mapper.addRule(prefix + "/Loader",
mapper.setProperties());
mapper.addRule(prefix + "/Loader", mapper.addChild
@@ -629,7 +638,7 @@
} else {
System.setProperty("catalina.useNaming", "true");
String value = "org.apache.naming";
- String oldValue =
+ String oldValue =
System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
if (oldValue != null) {
value = oldValue + ":" + value;
@@ -716,7 +725,7 @@
protected void usage() {
System.out.println
- ("usage: java org.apache.catalina.startup.Catalina"
+ ("usage: java org.apache.catalina.startup.Catalina"
+ " [ -config {pathname} ] [ -debug ]"
+ " [ -nonaming ] { start | stop }");
@@ -730,6 +739,91 @@
/**
+ * Class that copies the parentClassLoader property from the next-to-top
+ * item on the stack (which must be a Container) to the top item on the
+ * stack (which must also be a Container).
+ */
+
+final class CopyParentClassLoaderAction extends XmlAction {
+
+
+ /**
+ * Construct a new action.
+ */
+ public CopyParentClassLoaderAction() {
+ super();
+ }
+
+
+ /**
+ * Copy the required class loader.
+ */
+ public void start(SaxContext context) throws Exception {
+ if (context.getDebug() >= 1)
+ context.log("Copying parent class loader");
+ Stack stack = context.getObjectStack();
+ Container child = (Container) stack.pop();
+ Container parent = (Container) stack.peek();
+ stack.push(child);
+ child.setParentClassLoader(parent.getParentClassLoader());
+ }
+
+}
+
+
+/**
+ * Class that creates a new StandardLoader instance, with the parent class
+ * loader associated with the top object on the stack (which must be a
+ * Container), and pushes it on to the stack.
+ */
+
+final class CreateLoaderAction extends XmlAction {
+
+
+ /**
+ * Construct a new action.
+ */
+ public CreateLoaderAction() {
+ super();
+ }
+
+
+ /**
+ * Add the requested Loader implemenation.
+ */
+ public void start(SaxContext context) throws Exception {
+
+ // Look up the required parent class loader
+ Stack stack = context.getObjectStack();
+ Container container = (Container) stack.peek();
+ ClassLoader parentClassLoader = container.getParentClassLoader();
+
+ // Instantiate a new Loader implementation object
+ StandardLoader loader = new StandardLoader(parentClassLoader);
+
+ // Push the new loader onto the stack
+ stack.push(loader);
+ if (context.getDebug() >= 1)
+ context.log("new " + loader.getClass().getName());
+
+ }
+
+
+ /**
+ * Pop the loader off the top of the stack.
+ */
+ public void cleanup(SaxContext context) {
+ Stack stack = context.getObjectStack();
+ Object o = stack.pop();
+ if (context.getDebug() >= 1)
+ context.log("pop " + o.getClass().getName());
+
+ }
+
+}
+
+
+/**
* Class that adds a LifecycleListener for the top class on the stack.
*/
@@ -849,5 +943,3 @@
}
-
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]