tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Layman <randy.lay...@aswethink.com>
Subject RE: ClassNotFoundException
Date Wed, 27 Feb 2002 11:50:38 GMT

	I don't' believe what you are trying to do is possible.  Class
loaders are created in a hierarchical manner with the children knowing about
their parents, but not the parents knowing about the children.  This makes
it impossible for the current class loader (using Class.forName) to find the
class file loaded by a child class loader (which the WEB-INF is).

	I see that you have three options:
	1.  Engineer another solution to your problem
	2.  Move MyServletClass into common
	3.  Move MyBaseServletClass into all the WEB-INFs.

	Personally the order of approach I would take is 3, 2, and then 1.

	Randy

> -----Original Message-----
> From: Ken Ramirez [mailto:kramirez@mastermind.com]
> Sent: Wednesday, February 27, 2002 12:11 AM
> To: tomcat-user@jakarta.apache.org
> Subject: ClassNotFoundException
> 
> 
> Hope someone can help:
> 
> I have a TOMCAT app containing a servlet as follows:
> 
> <TOMCAT_HOME>/webapps/MyApp/WEB-INF/classes/com/mycomp/MyServl
> etClass.cl
> ass
> 
> This class extends a base class that provides common functionality for
> all of my apps, and is stored in:
> 
> <TOMCAT_HOME>/common/classes/com/mycomp/MyBaseServletClass.cla
> ss  (which
> extends HttpServlet)
> 
> Through some context information, the MyBaseServletClass receives the
> classname of a class stored in my app's classes directory, 
> which it is responsible for creating an instance of, using
> Class.forName().  This is the path of the class to be created:
> 
> <TOMCAT_HOME>/webapps/MyApp/WEB-INF/classes/com/mycomp/MyOther
> Class.clas
> s
> 
> When the MyServletClass calls Class.forName, it fails with a
> ClassNotFoundException, but if I move the MyServletClass 
> to the MyApp/WEB-INF/classes path, everything works fine.
> 
> What gives?  I thought that Tomcat reads adds the classes 
> directory for
> all of the apps deployed in the server.xml 
> (with Context info), which I defined as follows:
> 
>    <Context path="/MyApp" docBase="MyApp" debug="0" 
> reloadable="true" />
> 
> 
> Thanks,
> 
> Ken Ramirez - Principal/CTO
> kramirez@mastermind.com
>   
> Master-Mind Consulting Services
> http://www.mastermind.com <http://www.mastermind.com/> 
> Ph - 570-688-9600
> Fx - 208-275-2301
>  
> 
> 

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message