You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Richard Sayre <ri...@gmail.com> on 2008/09/29 13:20:31 UTC

Sharing Application Code Between Contexts

Is it possible to have several contexts pointing to the same code
base?  If I am hosing an application and other clients would like to
use it, is it possible to set them up a seprate context that points to
one set of JSP/Java Classes?

Are there disadvantages in doing this?

Thank you,

Rich

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


Re: Sharing Application Code Between Contexts

Posted by Mark Thomas <ma...@apache.org>.
Richard Sayre wrote:
> Is it possible to have several contexts pointing to the same code
> base?  If I am hosing an application and other clients would like to
> use it, is it possible to set them up a seprate context that points to
> one set of JSP/Java Classes?
Yes. How, depends on your Tomcat version. Look in the docs for shared
classloader.

> Are there disadvantages in doing this?
Yes. Various class-loading issues. Any changes to the common code require a
Tomcat restart. Potential incompatibility of dependencies.

Disk is cheap. Memory is cheap. A simpler solution is to provide the code
in a jar and let each web-app that wants to use it add that jar to WEB-INF lib.

Mark



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


Re: Sharing Application Code Between Contexts

Posted by Richard Sayre <ri...@gmail.com>.
Ok, thanks everyone for the help.  I will look into all suggestions.

Thanks,

Rich

On Mon, Sep 29, 2008 at 11:15 AM, Mikolaj Rydzewski <mi...@ceti.pl> wrote:
> Richard Sayre wrote:
>>
>> I specify a JNDI resources (connection pool) and an Authentication
>> Realm.  Each application authenticates from a different database, and
>> has a seprate connetion pool  there is a seprate database for each
>> app.
>>
>
> Define all environment specific details in server.xml (while declaring
> resources) and you can use the same context.xml and web.xml in any
> environment.
>
> --
> Mikolaj Rydzewski <mi...@ceti.pl>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Sharing Application Code Between Contexts

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Richard Sayre wrote:
> I specify a JNDI resources (connection pool) and an Authentication
> Realm.  Each application authenticates from a different database, and
> has a seprate connetion pool  there is a seprate database for each
> app.
>   
Define all environment specific details in server.xml (while declaring 
resources) and you can use the same context.xml and web.xml in any 
environment.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


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


Re: Sharing Application Code Between Contexts

Posted by Richard Sayre <ri...@gmail.com>.
I specify a JNDI resources (connection pool) and an Authentication
Realm.  Each application authenticates from a different database, and
has a seprate connetion pool  there is a seprate database for each
app.

On Mon, Sep 29, 2008 at 10:43 AM, Mikolaj Rydzewski <mi...@ceti.pl> wrote:
> Richard Sayre wrote:
>>
>> I use ant.  I am using Netbeans IDE for everything.  Basically I
>> always have to change the context.xml and web.xml for every
>> environment that I set up.  Everything else remains the same.
>>
>
> What kind of information do you pass through context.xml and web.xml? JNDI
> resources? If so, you can define them in server.xml and leave context.xml
> and web.xml untouched.
>
> --
> Mikolaj Rydzewski <mi...@ceti.pl>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Sharing Application Code Between Contexts

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Richard Sayre wrote:
> I use ant.  I am using Netbeans IDE for everything.  Basically I
> always have to change the context.xml and web.xml for every
> environment that I set up.  Everything else remains the same.
>   
What kind of information do you pass through context.xml and web.xml? 
JNDI resources? If so, you can define them in server.xml and leave 
context.xml and web.xml untouched.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


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


Re: Sharing Application Code Between Contexts

Posted by Richard Sayre <ri...@gmail.com>.
I use ant.  I am using Netbeans IDE for everything.  Basically I
always have to change the context.xml and web.xml for every
environment that I set up.  Everything else remains the same.

On Mon, Sep 29, 2008 at 9:46 AM, Mikolaj Rydzewski <mi...@ceti.pl> wrote:
> Richard Sayre wrote:
>>
>> Are there any tools that would help with building different .war files
>> for each context?
>>
>
> Do you build wars by hand or use Ant, Maven, etc?
>
> --
> Mikolaj Rydzewski <mi...@ceti.pl>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Sharing Application Code Between Contexts

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Richard Sayre wrote:
> Are there any tools that would help with building different .war files
> for each context?
>   
Do you build wars by hand or use Ant, Maven, etc?

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


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


Re: Sharing Application Code Between Contexts

Posted by Tim Funk <fu...@joedog.org>.
ANT should easily be able to do this. Then you should be able either use 
either of
1) properties
2) target

To build one or more apps a time. If your shared code are versioned 
well, maven might be a good fit too. (Since it has more dependency 
handling methodology in place)

-Tim

Richard Sayre wrote:
> Are there any tools that would help with building different .war files
> for each context?
> 
> On Mon, Sep 29, 2008 at 8:58 AM, Tim Funk <fu...@joedog.org> wrote:
>> 1) Disk is cheap.
>> 2) Build scripts can easily push the common code out to all your apps in a
>> reproducable manner.
>> 3) Seperate code makes regression upgrades easier to do since there is
>> always that one app which cant be upgraded
>>
>> While you may be "sharing code" - all the code will be living in different
>> classloaders (one per webapp) so at most - you are saving disk.
>>

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


Re: Sharing Application Code Between Contexts

Posted by Richard Sayre <ri...@gmail.com>.
What I mean is building a different WAR files, which has all the same
code, but different deployment descriptors.

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


Re: Sharing Application Code Between Contexts

Posted by Richard Sayre <ri...@gmail.com>.
Are there any tools that would help with building different .war files
for each context?

On Mon, Sep 29, 2008 at 8:58 AM, Tim Funk <fu...@joedog.org> wrote:
> 1) Disk is cheap.
> 2) Build scripts can easily push the common code out to all your apps in a
> reproducable manner.
> 3) Seperate code makes regression upgrades easier to do since there is
> always that one app which cant be upgraded
>
> While you may be "sharing code" - all the code will be living in different
> classloaders (one per webapp) so at most - you are saving disk.
>
> -Tim
>
>
> Richard Sayre wrote:
>>
>> Is it possible to have several contexts pointing to the same code
>> base?  If I am hosing an application and other clients would like to
>> use it, is it possible to set them up a seprate context that points to
>> one set of JSP/Java Classes?
>>
>> Are there disadvantages in doing this?
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Sharing Application Code Between Contexts

Posted by Tim Funk <fu...@joedog.org>.
1) Disk is cheap.
2) Build scripts can easily push the common code out to all your apps in 
a reproducable manner.
3) Seperate code makes regression upgrades easier to do since there is 
always that one app which cant be upgraded

While you may be "sharing code" - all the code will be living in 
different classloaders (one per webapp) so at most - you are saving disk.

-Tim


Richard Sayre wrote:
> Is it possible to have several contexts pointing to the same code
> base?  If I am hosing an application and other clients would like to
> use it, is it possible to set them up a seprate context that points to
> one set of JSP/Java Classes?
> 
> Are there disadvantages in doing this?


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