Could we use a URLClasLoader instead of the Classpath

2001-12-03 Thread Sriram Narayanan

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:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Solved : ClassNotFound Exception when loading Tomcat 4.0.1 via URLClassLoader

2001-11-30 Thread Sriram Narayanan

Hi all,

I've used the following workaround to address this problem.

I've created an executable jar for my UI class, and have added the bootstrap.jar file 
to the Class-Path manifest attribute. This works.

--- begin manifest fiel contents ---
Manifest-Version: 1.0
Main-Class: test.TCStart
Created-By: OESI
Class-Path: bin/bootstrap.jar bin/tools.jar
--- end manifest file contents ---

This lets me run the text.TCStart class, and load tomcat 4.0.1 and load tools.jar too.

What I'm planning to tackle next is asking the SystemClassLoader to load additional 
jars, the URLs/path of which I shall read form a properties file.

Regards,

Sriram



--- Start of forwarded message ---
From: Sriram Narayanan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Reply-To: Tomcat Developers List [EMAIL PROTECTED]
Subject: ClassNotFound Exception when loading Tomcat 4.0.1 via URLClassLoader
Date: 30/11/2001 9:24:34 AM

Hello all,

I'm trying to write a Swing based UI that'll help manage Tomcat.
Towards that end, I'm first trying to load Tomcat via a URLCLassLoader. This is so 
that one can load and test different Tomcat releases, and builds, and jar combinations.

My idea is to load Tomcat  via a URLCLassloader.
This thing works for Tomcat 3.3, but I'm facing the following problem with Tomcat 4.0.1

Any ideas ?

Thanks,

Sriram

--- Start of forwarded message ---
From: Sriram N [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Reply-To: Tomcat Developers List [EMAIL PROTECTED]
Subject: ClassNotFound Exception when loading Tomcat 4.0.1 via URLClassLoader
Date: 29/11/2001 6:43:02 PM

Hi all,

I'm trying to write a java class that will load Tomcat 4.0.1 for me.
My goal is:
- Do not use the classpath. The CLASSPATH env variable's contents are clear
be me first.
- Use the URLClassLoader to get started.

This technique works with Tomcat 3.3

With Tomcat 4.0.1 however, I get a ClassNotFoundException for
org.apache.catalina.loader.Reloader which is in the same bootstrap.jar that is
used to load 
org.apache.catalina.startup.Bootstrap

However, when I stick to the batch file which adds bootstrap.jar to the system
CLASSPATH, tomcat runs OK, as usual.

Could some one point me to what I'm missing or doing wrong ? Thanks.

Here's the code that I use to load Tomcat 4.0.1

-- begin code 
public class TCStart{
public static void main(String args[]){
try{
System.setProperty(catalina.home,f:/tc4.0.1/);
System.setProperty(catalina.base,f:/tc4.0.1/);
System.setProperty(java.class.path,);

java.io.File file = new 
java.io.File(f:/tc4.0.1/bin/bootstrap.jar);
java.net.URL[] urls = new java.net.URL[]{file.toURL()};
java.net.URLClassLoader loader = new 
java.net.URLClassLoader(urls);
Class aClass = 
loader.loadClass(org.apache.catalina.startup.Bootstrap);
String classLoaderName = 
aClass.getClassLoader().getClass().getName();
String className = aClass.getName();
System.out.println(ClassName  + className);
System.out.println(ClassLoader  + classLoaderName);
//Class aClass = 
Class.forName(org.apache.catalina.startup.Bootstrap);
java.lang.reflect.Method method = null;
Class[] argsClass = new Class[] { String[].class };
// get the main method for the org.apache.tomcat.shell.Startup 
class
method = aClass.getMethod(main, argsClass);
Object object = null;
String filePath= -f conf/server.xml;
Object[] arguments = new Object[] { new String[] {start}};
// now invoke the main method for the 
org.apache.tomcat.shell.Startup class
method.invoke(object, arguments);
}catch(Exception ex){
System.err.println(Ugh ! is all that I can say);
ex.printStackTrace(System.err);
}
}
}


-- end code ---

And here's the stack Trace that I get.

 begin stack trace dump ---
ClassName org.apache.catalina.startup.Bootstrap
ClassLoader java.net.URLClassLoader
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

ClassNotFound Exception when loading Tomcat 4.0.1 via URLClassLoader

2001-11-29 Thread Sriram Narayanan

Hello all,

I'm trying to write a Swing based UI that'll help manage Tomcat.
Towards that end, I'm first trying to load Tomcat via a URLCLassLoader. This is so 
that one can load and test different Tomcat releases, and builds, and jar combinations.

My idea is to load Tomcat  via a URLCLassloader.
This thing works for Tomcat 3.3, but I'm facing the following problem with Tomcat 4.0.1

Any ideas ?

Thanks,

Sriram

--- Start of forwarded message ---
From: Sriram N [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Reply-To: Tomcat Developers List [EMAIL PROTECTED]
Subject: ClassNotFound Exception when loading Tomcat 4.0.1 via URLClassLoader
Date: 29/11/2001 6:43:02 PM

Hi all,

I'm trying to write a java class that will load Tomcat 4.0.1 for me.
My goal is:
- Do not use the classpath. The CLASSPATH env variable's contents are clear
be me first.
- Use the URLClassLoader to get started.

This technique works with Tomcat 3.3

With Tomcat 4.0.1 however, I get a ClassNotFoundException for
org.apache.catalina.loader.Reloader which is in the same bootstrap.jar that is
used to load 
org.apache.catalina.startup.Bootstrap

However, when I stick to the batch file which adds bootstrap.jar to the system
CLASSPATH, tomcat runs OK, as usual.

Could some one point me to what I'm missing or doing wrong ? Thanks.

Here's the code that I use to load Tomcat 4.0.1

-- begin code 
public class TCStart{
public static void main(String args[]){
try{
System.setProperty(catalina.home,f:/tc4.0.1/);
System.setProperty(catalina.base,f:/tc4.0.1/);
System.setProperty(java.class.path,);

java.io.File file = new 
java.io.File(f:/tc4.0.1/bin/bootstrap.jar);
java.net.URL[] urls = new java.net.URL[]{file.toURL()};
java.net.URLClassLoader loader = new 
java.net.URLClassLoader(urls);
Class aClass = 
loader.loadClass(org.apache.catalina.startup.Bootstrap);
String classLoaderName = 
aClass.getClassLoader().getClass().getName();
String className = aClass.getName();
System.out.println(ClassName  + className);
System.out.println(ClassLoader  + classLoaderName);
//Class aClass = 
Class.forName(org.apache.catalina.startup.Bootstrap);
java.lang.reflect.Method method = null;
Class[] argsClass = new Class[] { String[].class };
// get the main method for the org.apache.tomcat.shell.Startup 
class
method = aClass.getMethod(main, argsClass);
Object object = null;
String filePath= -f conf/server.xml;
Object[] arguments = new Object[] { new String[] {start}};
// now invoke the main method for the 
org.apache.tomcat.shell.Startup class
method.invoke(object, arguments);
}catch(Exception ex){
System.err.println(Ugh ! is all that I can say);
ex.printStackTrace(System.err);
}
}
}


-- end code ---

And here's the stack Trace that I get.

 begin stack trace dump ---
ClassName org.apache.catalina.startup.Bootstrap
ClassLoader java.net.URLClassLoader
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)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:612)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)

at

Class or Interface

2001-11-24 Thread Sriram Narayanan

Hi,

I just went over to 

http://nagoya.apache.org/~pier/documentation/api-java/org/apache/catalina/connector/warp/Constants.html

And saw that this is defined as a Class rather than as an Interface. I'd like to 
understand the rationale behind this.

Also, if there some other place where I must ask such questions, please point it out.

Thanks,

Sriram



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


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




Re: Tomcat and Visualage for Java 4.0

2001-10-18 Thread Sriram Narayanan

Hi,

I use VaJava myself, and have written a Tomcat Test Environment too. All that I do 
is invoke the main method actually...

However, I find that what runs within VA often does not run outside of it. Either 
classes do not get loaded, or response.sendRedirect needs to be used in place of 
request despatching. I'm aware that these problems may be due to coding problems on my 
part.

So what I do is
- Do initial testing and debuggin within VA. VA is just great for debugging.
- Once the workflow is implemented, test the same code outside of VA.

Sriram

13/10/2001 2:20:47 AM, Hein [EMAIL PROTECTED] wrote:

Dear Tomcat dev. team,
 
Is there a version of the product mentioned in the following posting that 
orks with VA Java 4.0 ?
 
http://w6.metronet.com/~wjm/tomcat/2000/Aug/msg00664.html
 
Greetings from an experienced (and satisfied) Tomcat user from Holland,
Hein






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