Web Applications, static variables and classloaders
1 posts in topic
Flat View  Flat View

Posted By:   David_Garcia
Posted On:   Friday, August 30, 2002 02:39 AM

Hi all, I have doubts about web applications and static variables.

Supposed Problem Description:

I define a static class variable and I use this class within multiple web application running simultaneously in the same Application Server.

I beleive that the static variable is unique per classloader, so, if the classloader is unique per AppServer, then all the web applications are sharing the static variable.

Is this true?

Thanks in advance for the attention, DG

Re: Web Applications, static variables and classloaders

Posted By:   Lasse_Koskela  
Posted On:   Friday, August 30, 2002 07:27 AM

The classloader hierarchy is pretty much appserver-specific.

Usually, I guess, the appserver creates one classloader for each application (.ear) and one child-classloader for each web-app (.war) within the application. The application classloaders are children of the system classloader.

When a classloader tries to load a class, it doesn't ask from its children, only from its parent classloader, so keep this in mind if/when you run into problems.

There are a couple of articles around the web about the J2EE classloader hierarchies of some appservers.

About | Sitemap | Contact