On Sat, 19 Oct 2002, shanmugampl wrote:
> Date: Sat, 19 Oct 2002 14:29:41 +0530 > From: shanmugampl <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: Accessing classes across contexts > > Hi, > > I have two web applications running in my tomcat. Can i access the > classes present in one of my applications from the other?. No. The classes inside each webapp are loaded from separate class loaders, and each webapp can only see its own. > In my case one application contains some utility classes which are > required by the other application. I do not want to duplicate the > utility classes and also it is not possible for me to move the class > files outside my context. Is it possible to achieve this by setting the > cross context to true in the server.xml. > The only way to share classes across webapps is to put those classes into a class loader that is the parent of the webapp class loaders. For Tomcat, that means putting them in $CATALINA_HOME/shared/lib or $CATALINA_HOME/common/lib. However, this is specific to Tomcat. See the following for more info on how class loading in Tomcat works: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html That being said, I would strongly recommend that you not worry about duplication -- just set up your build environment so that you copy the appropriate version of the dependent JAR files into each webapp (from their single location in your source directories) as needed. That way, you can independently start, stop, and upgrade the webapps without having to shut down and restart the entire server every time. > Thanks > Shanmugam.PL Craig -- To unsubscribe, e-mail: <mailto:tomcat-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>
