You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Sriram Narayanan <sr...@yahoo.com> on 2001/12/03 19:05:59 UTC

Could we use a URLClasLoader instead of the Classpath

Hi,

I've just come across a response by Craig listing the various problems that one cafes because we often do not have control over the CLASSPATH and the lib/ext problems 
too..

I'm trying to write some sort of an application launcher, that accepts configuration directives via a properties file and loads applications..
Here's how a properties file looks..

className= com.objectedge.tomcat.management.ui.TomcatControllerView
staticMethod=main
argument1=start
jarFile1=.\\lib\\stop-tomcat.jar
jarFile2=.\\lib\\tomcat.jar
jarFile3=.\\lib\\common\\connector_util.jar
jarFile4=.\\lib\\common\\core_util.jar
jarFile5=.\\lib\\common\\etomcat.jar
jarFile6=.\\lib\\common\\jasper-runtime.jar
jarFolder1=c:\Sample


I read the properties file, asemble URLs from the JarFile and JarFilder properties, and pass the whole array to a URLCLassLoader.
Then I ask the URLClassloader for what ever class is mentioned in the className property, and invoke the mentioned static method on it.

Well, the above is what I've got working for Tomcat 3.3

When I try to do somthing similar for TC 4.x , I load the bootstrap.jar and the tools.jar files successfully.
However I get the follwing stack trace and then it all stops.

--begin partial stack trace dump---
ClassName org.apache.catalina.startup.Bootstrap					// this is some info that I print for myself
ClassLoader java.net.URLClassLoader						// this too..
Starting service Tomcat-Standalone
Apache Tomcat/4.0.1
Exception during startup processing
java.lang.reflect.InvocationTargetException: java.lang.NoClassDefFoundError:
org
/apache/catalina/loader/Reloader
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at
org.apache.catalina.loader.StandardClassLoader.findClass(StandardClas
sLoader.java:671)
        at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClas
sLoader.java:1090)
        at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClas
sLoader.java:989)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3
313)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)

--- cut off here ---

I've just begun to read the VM spec, and the Language Spec, and just finished downloading the Tomcat 4 source to understand classloading in that.

Could some one please tell me what's exactly happening in this stack trace ?

Sriram



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>