You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jerome Lepage - AKEROZ <j....@akeroz.net> on 2008/10/24 11:25:43 UTC

Question about Tomcat context

Hi @ll,

I have developped a web application on Tomcat (5.0.28).
My webapp use Hibernate 3 and i have a Singleton pattern too.

I want have my webapp deployed N time in same Tomcat Server.
But i don't want to share context, hibernate and Singleton from one webapp to other.
(Like database access is not the same)

I have see in tomcat doc, the "share context" parameters but i don't have tried at this time.
(Or maybe in différent tomcat "vhost")

My question is, is it possible or not, and if yes how (almost a direction or a clue will be perfect).

Thanks by advance for your time.

Jerome Lepage
AKEROZ

RE: Question about Tomcat context

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Peter Crowther [mailto:Peter.Crowther@melandra.com]
> Subject: RE: Question about Tomcat context
>
> > From: Jerome Lepage - AKEROZ [mailto:j.lepage@akeroz.net]
> > JAVA_OPTS="-XX:MaxPermSize=512m -Xms24m -Xmx512m"

For server environments, you usually want to set Xms to the same value as Xmx to avoid heap thrashing.  Make sure you have enough RAM on the system to support not only the Java heap and PermGen spaces, but also the C heap, code space, and library/OS overhead.  If you don't have enough RAM, you'll get into paging, and your performance will disappera.

> > It's seems that tomcat have the memory but don't give to the
> > différents contexts

Heap memory is shared across all webapps, since they're all running in the same JVM; there's no way to provide separate heap space for each webapp.

> I'm simplifying here - you're better off reading the JVM docs
> or waiting for Chuck* to tell me I'm wrong ;-).

Nothing wrong here.

> Low free memory is not necessarily a problem - the
> JVM may just be being lazy about garbage collection.

Try using JConsole to watch the heap and PermGen while Tomcat's running; this will show if you are approaching a tight situation on memory space. (JVisualVM can also be used, but it's not as detailed.)

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
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: Question about Tomcat context

Posted by Peter Crowther <Pe...@melandra.com>.
> From: Jerome Lepage - AKEROZ [mailto:j.lepage@akeroz.net]
> But when i launch tomcat with this env vars :
> JAVA_OPTS="-XX:MaxPermSize=512m -Xms24m -Xmx512m"

Well, yes :-).  That should give you enough perm space.

> Tomcat looks like not really care about the memory i grant to JVM.
> It's seems that tomcat have the memory but don't give to the
> différents contexts
> I have a poor "Free memory" at each time...

I'm simplifying here - you're better off reading the JVM docs or waiting for Chuck* to tell me I'm wrong ;-).  Any Java virtual machine will only collect garbage a) when you tell it (and sometimes not then), or b) when it runs out of free memory and needs to allocate something.  Low free memory is not necessarily a problem - the JVM may just be being lazy about garbage collection.

                - Peter

* who has forgotten more about Java virtual machines than I will ever learn

---------------------------------------------------------------------
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: Question about Tomcat context

Posted by Jerome Lepage - AKEROZ <j....@akeroz.net>.
Hi, Thanks to you too for your answers.

> Have you tried just deploying it N times, making sure all the jars are in WEB-INF/lib?
> Each webapp should get its own classloader, and hence will have its own copies
> of Hibernate and your singleton.  I *think* they'll have different contexts, too,
> but I've not tried this.

No i don't have tried at this time, i'm in "beta" version so i try to anticipate this problem before i was at this part :)
Ok i will try, thanks

> By the way: if you start getting out of memory errors as you deploy more copies,
> make sure you have enough perm space configured in your JVM options.  
> Hibernate can generate a lot of classes, and lots of copies of these classes can
> consume a lot of perm space.

I'm glade to discuss about that.
I'm aware that hibernate is a big giant library wich use lot of memory.
But when i launch tomcat with this env vars :
JAVA_OPTS="-XX:MaxPermSize=512m -Xms24m -Xmx512m"

Tomcat looks like not really care about the memory i grant to JVM.
It's seems that tomcat have the memory but don't give to the différents contexts
I have a poor "Free memory" at each time...

Is it something i miss or not ?

Thanks again to you

Jerome Lepage
AKEROZ

RE: Question about Tomcat context

Posted by Peter Crowther <Pe...@melandra.com>.
> From: Jerome Lepage - AKEROZ [mailto:j.lepage@akeroz.net]
> I have developped a web application on Tomcat (5.0.28).
> My webapp use Hibernate 3 and i have a Singleton pattern too.
>
> I want have my webapp deployed N time in same Tomcat Server.
> But i don't want to share context, hibernate and Singleton
> from one webapp to other.
> (Like database access is not the same)

Have you tried just deploying it N times, making sure all the jars are in WEB-INF/lib?  Each webapp should get its own classloader, and hence will have its own copies of Hibernate and your singleton.  I *think* they'll have different contexts, too, but I've not tried this.

By the way: if you start getting out of memory errors as you deploy more copies, make sure you have enough perm space configured in your JVM options.  Hibernate can generate a lot of classes, and lots of copies of these classes can consume a lot of perm space.

                - Peter

---------------------------------------------------------------------
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: Question about Tomcat context

Posted by Serge Fonville <se...@gmail.com>.
Hi Jerome.

If you save everything that is specific to the context in that context, they
operate as separate.
Regards,

Serge Fonville

On Fri, Oct 24, 2008 at 12:02 PM, Jerome Lepage - AKEROZ <
j.lepage@akeroz.net> wrote:

>
> Hi, Thanks for quick answers
>
> My app is a Cms
> The sources, wars, deploy method is the same.
> Only a "Environement String" (pointing to a specific config dir) is
> différent with Context.
>
> I don't want to they share anything at all, because is not same customers
> for each context.
> So for security reason, i don't want to share (even i loose memory and
> space).
>
> My customers don't have access to tomcat at all (except the app off
> course).
> I will deploy, upgrade, remove, etc.. so if easyer it's better, but i don't
> really care about that.
>
> I have already separate context for previous version of my app.
> But i'm (was) not sure for sharing "rules" of tomcat in Singleton or
> Hibernate case.
> (Because the goal of a singleton by definition is to have unique instance)
> I was affraid in test, who i have see my Log4J logs in wrong directory
> (maybe it's because is in "common/lib" dir)
>
> So if i understand well, if the library(s) is not in "common/lib" but in
> "WEB-INF/lib" they don't share context ?
>
> Thanks again for your time and answers..
>
> Jerome Lepage
> AKEROZ
>
>
> ----- Original Message -----
> From: "Serge Fonville" <se...@gmail.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Friday, October 24, 2008 11:37 AM
> Subject: Re: Question about Tomcat context
>
>
> First a few questions;
> What does the app do
> Do the deployed applications differ
> What is the reason you want them separate
> Do they share anything, reaml,db,files,....
> Do you need to be able to update them easily (all in one go)
> How do you intend to deploy them, war, copy, remote
> Is it an option to upgrade to Tomcat 6.0
>
> That said:
>
> By simply copying the same files to different contexts you have the same
> application available multiple times under different URLs.
>
> Regards,
>
> Serge Fonville
>
> On Fri, Oct 24, 2008 at 11:25 AM, Jerome Lepage - AKEROZ <
> j.lepage@akeroz.net> wrote:
>
> >
> > Hi @ll,
> >
> > I have developped a web application on Tomcat (5.0.28).
> > My webapp use Hibernate 3 and i have a Singleton pattern too.
> >
> > I want have my webapp deployed N time in same Tomcat Server.
> > But i don't want to share context, hibernate and Singleton from one
> webapp
> > to other.
> > (Like database access is not the same)
> >
> > I have see in tomcat doc, the "share context" parameters but i don't have
> > tried at this time.
> > (Or maybe in différent tomcat "vhost")
> >
> > My question is, is it possible or not, and if yes how (almost a direction
> > or a clue will be perfect).
> >
> > Thanks by advance for your time.
> >
> > Jerome Lepage
> > AKEROZ
>

Re: Question about Tomcat context

Posted by Jerome Lepage - AKEROZ <j....@akeroz.net>.
Hi, Thanks for quick answers

My app is a Cms
The sources, wars, deploy method is the same.
Only a "Environement String" (pointing to a specific config dir) is différent with Context.

I don't want to they share anything at all, because is not same customers for each context.
So for security reason, i don't want to share (even i loose memory and space).

My customers don't have access to tomcat at all (except the app off course).
I will deploy, upgrade, remove, etc.. so if easyer it's better, but i don't really care about that.

I have already separate context for previous version of my app.
But i'm (was) not sure for sharing "rules" of tomcat in Singleton or Hibernate case.
(Because the goal of a singleton by definition is to have unique instance)
I was affraid in test, who i have see my Log4J logs in wrong directory (maybe it's because is in "common/lib" dir)

So if i understand well, if the library(s) is not in "common/lib" but in "WEB-INF/lib" they don't share context ?

Thanks again for your time and answers..

Jerome Lepage
AKEROZ


----- Original Message ----- 
From: "Serge Fonville" <se...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Friday, October 24, 2008 11:37 AM
Subject: Re: Question about Tomcat context


First a few questions;
What does the app do
Do the deployed applications differ
What is the reason you want them separate
Do they share anything, reaml,db,files,....
Do you need to be able to update them easily (all in one go)
How do you intend to deploy them, war, copy, remote
Is it an option to upgrade to Tomcat 6.0

That said:

By simply copying the same files to different contexts you have the same
application available multiple times under different URLs.

Regards,

Serge Fonville

On Fri, Oct 24, 2008 at 11:25 AM, Jerome Lepage - AKEROZ <
j.lepage@akeroz.net> wrote:

>
> Hi @ll,
>
> I have developped a web application on Tomcat (5.0.28).
> My webapp use Hibernate 3 and i have a Singleton pattern too.
>
> I want have my webapp deployed N time in same Tomcat Server.
> But i don't want to share context, hibernate and Singleton from one webapp
> to other.
> (Like database access is not the same)
>
> I have see in tomcat doc, the "share context" parameters but i don't have
> tried at this time.
> (Or maybe in différent tomcat "vhost")
>
> My question is, is it possible or not, and if yes how (almost a direction
> or a clue will be perfect).
>
> Thanks by advance for your time.
>
> Jerome Lepage
> AKEROZ

Re: Question about Tomcat context

Posted by Serge Fonville <se...@gmail.com>.
First a few questions;
What does the app do
Do the deployed applications differ
What is the reason you want them separate
Do they share anything, reaml,db,files,....
Do you need to be able to update them easily (all in one go)
How do you intend to deploy them, war, copy, remote
Is it an option to upgrade to Tomcat 6.0

That said:

By simply copying the same files to different contexts you have the same
application available multiple times under different URLs.

Regards,

Serge Fonville

On Fri, Oct 24, 2008 at 11:25 AM, Jerome Lepage - AKEROZ <
j.lepage@akeroz.net> wrote:

>
> Hi @ll,
>
> I have developped a web application on Tomcat (5.0.28).
> My webapp use Hibernate 3 and i have a Singleton pattern too.
>
> I want have my webapp deployed N time in same Tomcat Server.
> But i don't want to share context, hibernate and Singleton from one webapp
> to other.
> (Like database access is not the same)
>
> I have see in tomcat doc, the "share context" parameters but i don't have
> tried at this time.
> (Or maybe in différent tomcat "vhost")
>
> My question is, is it possible or not, and if yes how (almost a direction
> or a clue will be perfect).
>
> Thanks by advance for your time.
>
> Jerome Lepage
> AKEROZ