tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sriram Narayanan <sriram...@gmail.com>
Subject Using a CustomClassLoader for my WebApp
Date Tue, 10 Jan 2006 23:11:23 GMT
Hi:

I'm trying to create a CustomClassLoader that I could use as my Web
App's classloader.
But I've been unsuccessful so far.

The problem:
==========================================================
When I create a JSP with the content :
<%
	Class clazz  = Class.forName("com.testing.junk.Cyber");
	Object anObject = clazz.newInstance();
	String value = anObject.toString();
%>

The text is <%=value%>
===========================================================

I get the exception:
===========================================================
root cause

java.lang.ClassNotFoundException: com.testing.junk.Cyber
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:127)
	org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
	java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	java.lang.Class.forName0(Native Method)
	java.lang.Class.forName(Class.java:164)
	org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:44)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

===========================================================

Here's what I'm doing:

1. I've read the documents at :
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
and
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

2. I've created the class MyClassLoader which extends
WebappClassLoader and placed it at
This class calls super.addRepository("d:/temp/bin/") via its constructors.

3. I've placed MyClassLoader at ${catalina.home}/server/classes

4. My ${catalina.home}/webapps/test.xml file has the contents

 <Context docBase="d:/temp/test"
         privileged="false" antiResourceLocking="false" antiJARLocking="false">

  <Loader classname="com.testing.tomcat.loader.ConfigurableClasspathWebappClassLoader"
classpathEntriesFile="d:\\temp\\abc.properties" />

</Context>

5. The class com.testing.junk.Cyber is placed at d:/temp/bin

-- Sriram

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message