Hi
I want to change the shared classloader of Embedded Tomact ,so that
some of the jar file required for my Application will be loaded
from a separeate directory..I am using a *URLClassLoader *.and using
org.apache.catalina.startup.Catalina to start the tomcat using
conf/server.xml file.I m getting no problem in server startup but the jars i
want to load through shared loader doesnot get loaded. Below is the details
of the code..
**
*import org.apache.catalina.*;
import org.apache.catalina.loader.*;
import org.apache.catalina.users.*;
import org.apache.catalina.realm.*;
import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.log.SystemLogHandler;
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.catalina.startup.*;*
* *
*public class CatStarter {*
*/** Creates a new instance
of CatStarter */
public CatStarter() {*
* }*
* public static void main(String[] args) throws Exception{
List ls=new ArrayList();
File[] allfiles;
URL[] temp=new URL[2];
File f1=new File("C://tmp//lib//");
allfiles=f1.listFiles();
for(int i=0;i<allfiles.length;i++)
{
ls.add(allfiles[i].toURL());
}
Catalina cat=new Catalina();*
*cat.setParentClassLoader(new URLClassLoader((URL[])ls.toArray(temp)));*
*System.setProperty( "catalina.base", "c:\\Tmc5em");*
*try *
*{
//cat.process( new String[] { "start" });
cat.start();
} *
*catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
}*
**
i have a context named Test thats in the Webapp directory of TomcatBase .In
the web.xml file of Test i have mentioned this -->
*<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
xmlns="**http://java.sun.com/xml/ns/j2ee*<http://java.sun.com/xml/ns/j2ee>
*"
xmlns:xsi="**http://www.w3.org/2001/XMLSchema-instance*<http://www.w3.org/2001/XMLSchema-instance>
*"
xsi:schemaLocation="**http://java.sun.com/xml/ns/j2ee*<http://java.sun.com/xml/ns/j2ee>
*
**http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd*<http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd>
*"
version="2.4">
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>precompilejsp.HelloWorldExample</servlet-class>
</servlet>*
*<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello.jsp</url-pattern>
</servlet-mapping>
</web-app>*
the precompilejsp.HelloWorldExample.class file lies in the test.jar file
located in c:/tmp/lib directory which i m loading through URLClassLoader as
mentioned in the above programm. But this does not seem to work as i m
getting error ClassNotFound (*precompilejsp.HelloWorldExample ) *while
acessing Test/hello.jsp .
But by including test.jar in java classpath i can view the servlet so that
means my ClassLoader is not working properly.
So please answer me the solution...
regards
Suvendu