Thanks a lot for helping me understand all this concepts about
classloading. I found a pretty good article on class loading in java.
http://www.onjava.com/pub/a/onjava/2005/01/26/classloading.html

Thanks,
Anshaj


On Thu, 03 Feb 2005 22:25:53 +0100, Mario Winterer
<[EMAIL PROTECTED]> wrote:
> For more information on tomcat's classloading concept have a look at:
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/class-loader-howto.html
> 
> As you can see there, Tomcat instantiates a classloader for each web
> application. So if you put a class - let's say "Global" - inside the
> "WEB-INF/classes" directory of each of two of your web applications, it
> will be loaded twice. As a fact, a static variable of the "Global" class
> - let's say Global.myVar - will exist twice too!
> But if you put your "Global" class into the %TOMCAT_HOME%/shared/classes
> directory ONLY (important: you must remove all occurences of your
> "Global" class from the webapps-classes directories to make this work!),
> it will be loaded by the "shared"-classloader. Because of the fact that
> the shared classloader is the parent classloader of all
> webapp-classloaders, every web-application can access the classes loaded
> by the shared classloader.
> 
> But holding resources in static variables inside the shared/classes
> directory there is not recommmended! Better add a JNDI-resource to your
> Tomcat's JNDI-context! This is done in server.xml inside the
> <GlobalNamingResources>-element* *(see
> http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/globalresources.html).
> 
> Best regards,
>   Tex
> 
> 
> >Thanks for your reply. I think JVM rules said that there should be 1
> >reference per JVM for a static variable. Tomcat class loader creates
> >separate instance of a static variable for each webapps. I am just
> >trying to understand how class loader works in tomcat.
> >
> >Thanks,
> >Anshaj
> >
> >
> >On Thu, 03 Feb 2005 06:41:29 -0500, Tim Funk <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Put the class in the common or shared classloader.
> >>
> >>-Tim
> >>
> >>Anshaj Mathur wrote:
> >>
> >>
> >>
> >>>Dear group,
> >>>
> >>>         I have public class which contains a static
> >>>variable type integer. I am running different webapps
> >>>inside single instance of tomcat. I initiated this
> >>>class in different webapps. I increased the count from
> >>>a webapp and tried to see it from different webapp. I
> >>>found that count was not increased in other webapp. It
> >>>was showing the original count.
> >>>Am I braking any laws of tomcat security.
> >>>
> >>>
> >>>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
v1.2a r TW 0/0/ FD + 0 DSotM 3 100 21.3% <3jan5>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to