You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ulrich Mayring <ul...@denic.de> on 2003/09/05 10:19:07 UTC

How to use classes from another webapp/context?

Hello,

I know that Tomcat has seperate classloaders for each webapp, but what I 
would like to do is have JSPs in one webapp and the classes they use in 
another. I tried enabling the crossContext feature for the relevant 
contexts, but that didn't work, the classes weren't found.

Background: we have editors, who write and deploy JSP files, and 
programmers, who write and deploy classes used by JSP files. I would 
like to have the editors manage their webapps with the JSP files via the 
HTML manager and the programmers to do the same for their webapps.

I know that I could put the classes under the shared directory, but then 
they would not be in a webapp anymore and thus management via the HTML 
manager would not work anymore. Tomcat would need to be restarted on 
every change.

I could also have the programmers give JAR files to the editors and have 
the editors deploy them with their webapps, but then the classes would 
be duplicated across many webapps and also I don't want the editors 
handling JAR files.

Is there any solution?

Thanks in advance for any pointers,

Ulrich



Re: How to use classes from another webapp/context?

Posted by Marco Tedone <mt...@jemos.org>.
Well, usually a WAR is a composite collection of JSPs, classes, deployment
descriptor, third-party jars and so on. If you have people who write
classes, they can create a jar, not a war, and people who create JSP can
just place them in the correct location. A good build project could then
merge the classes, the JSPs and whatever needed in a single, composite, war
file. Need to change a behaviour? Modify the class and redeploy the
application. Need to change layout? Change the JSP and copy/redeploy to the
correct location (Additionally restart the server :)

My 2 cents,

Marco
----- Original Message ----- 
From: "Ulrich Mayring" <ul...@denic.de>
To: <to...@jakarta.apache.org>
Sent: Monday, September 08, 2003 10:25 AM
Subject: Re: How to use classes from another webapp/context?


> Christopher Williams wrote:
> >
> > Unfortunately, you do need to move classes common to multiple web apps
into
> > library files.  You don't have to put the library files into common\lib,
> > however.  You can put the JARs in WEB-INF/lib inside your WAR file.
Never
> > done it myself, but it's supposed to work.
>
> Yep, but then I can't deploy/undeploy the two WARs seperately. We have
> developers, who write classes, and they want to manage their WAR, and we
> have people, who write JSP files, and they want to manage their own WAR.
> But it seems they can't work together in the way I imagined.
>
> Thank you very much for your help,
>
> Ulrich
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>




Re: How to use classes from another webapp/context?

Posted by Ulrich Mayring <ul...@denic.de>.
Christopher Williams wrote:
> 
> Unfortunately, you do need to move classes common to multiple web apps into
> library files.  You don't have to put the library files into common\lib,
> however.  You can put the JARs in WEB-INF/lib inside your WAR file.  Never
> done it myself, but it's supposed to work.

Yep, but then I can't deploy/undeploy the two WARs seperately. We have 
developers, who write classes, and they want to manage their WAR, and we 
have people, who write JSP files, and they want to manage their own WAR. 
But it seems they can't work together in the way I imagined.

Thank you very much for your help,

Ulrich



Re: How to use classes from another webapp/context?

Posted by Christopher Williams <cc...@ntlworld.com>.
Let's say you have a web app and it's stored in my_app1.war.  Then you have
a second web app stored in my_app2.war and you want to use some really neat
classes defined in my_app1.war.  So you add my_app1.war to your second
application's classpath and stick "import com.me.my_stuff.really_neat_class"
in one of your source files.  Your compiler will complain that it can't find
"really_neat_class" because it does not have the path com/me/my_stuff, it's
in WEB-INF/classes/com/me/my_stuff instead.  Bummer.

Unfortunately, you do need to move classes common to multiple web apps into
library files.  You don't have to put the library files into common\lib,
however.  You can put the JARs in WEB-INF/lib inside your WAR file.  Never
done it myself, but it's supposed to work.

----- Original Message ----- 
From: "Ulrich Mayring" <ul...@denic.de>
To: <to...@jakarta.apache.org>
Sent: Monday, September 08, 2003 8:53 AM
Subject: Re: How to use classes from another webapp/context?


> Christopher Williams wrote:
> > Easiest method:
> >
> > Put JSPs in WAR and stick in webapps
> > Put classes in JAR and stick in common\lib
>
> I'd rather use a more complicated method, if that would allow me to put
> my classes in WARs as well :)
>
> Ulrich
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



Re: How to use classes from another webapp/context?

Posted by Ulrich Mayring <ul...@denic.de>.
Christopher Williams wrote:
> Easiest method:
> 
> Put JSPs in WAR and stick in webapps
> Put classes in JAR and stick in common\lib

I'd rather use a more complicated method, if that would allow me to put 
my classes in WARs as well :)

Ulrich



Re: How to use classes from another webapp/context?

Posted by Christopher Williams <cc...@ntlworld.com>.
Easiest method:

Put JSPs in WAR and stick in webapps
Put classes in JAR and stick in common\lib