You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Dan Hansen <DH...@creo.com> on 2003/01/08 18:56:14 UTC

problems with ClassLoader and custom Server class.

Hi all,
 
 I've encountered a peculiar problem writing a Server for catalina (tomcat
4.1.18)

 I don't know if anyone else has written a customized Server so I
 don't know if this is uncharted territory or not - I saw nothing in my
 search of the archives but I might have missed it.  
 
 The key problem is that a new Server put into a jar into the 
 server/lib or common/lib directly results in one or another 
 of the ClassLoaders becoming unable to see other basic classes 
 in that catalina.jar (and others if you
 just naively put catalina.jar into the CLASSPATH to make it 
 available globally).
 
 Background Notes (in no particular order)
 1. You can replace the standard Server with your implementation via
 the className attribute in server configuration.
 2. You can make this class visible to the server by placing it in a
 jar in common/lib or in server/lib.
 3. Tomcat has different ClassLoaders for different portions of the
 container and web apps running on the container

 In other words, resources may be visible in one portion of the
 container and not in others.
 So if you write a MyServer class, put in a jar, and place it in (say)
 shared/lib - this will not work because the server needs to see the
 class and the shared portion is only visible to webapps.

 Here's the problem - write your MyServer class, put it in
 common/lib or server/lib.  Now when you try to run "catalina.bat run" 
 the ClassLoader cannot see org.apache.catalina.core.LifeCycle
 (which lives in the same package and jar as the StandardServer in the
 server portion of the container - i.e. catalina.jar).
 
 Heck, you don't even have to write your own class.  Put the
 StandardServer into your own package and jar in common/lib or server/lib
and you
 have the same problem.

 If you've got any insight into this problem I'd be in your debt.
 Dan

Dan Hansen | software engineer | +1.720.932.4724 | dan.hansen@creo.com |
www.creo.com
Creo - Creative Software Group

IMAGINE CREATE BELIEVE





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