Hello Duane!

I feel like it should be mandated, but a quick search of the servlet
2.2 spec has given me nothing, except serveral places where the
spec talks about an application class loader. So we can conclude that
application classloader is implied..

BTW "Christopher K. St. John" <[EMAIL PROTECTED]> has very
correctly remarked that what I was speaking about is true
only for classes loaded from WEB-INF/classes or WEB-INF/lib/*.jar
If the jar is on the classpath then it is shared.

DM> Does the spec say that this is the required behavior, or is this where one
DM> implementation
DM> can vary from another?  A colleague said that he tried the experiment with
DM> JRun 3.1, running
DM> 2 copies of the same application, and a static counter variable that was
DM> incremented only
DM> at startup ended up with a value of 2.
Very surprising! Maybe the class was loaded from some jar on the
classpath or some JRun shared library dir? (I'm not familiar with
JRun, so I do not know if it has a shared lib dir (it should) and
how it is named)

DM> Duane Morse, Eldorado Computing Inc., Phoenix, Arizona


DM> -----Original Message-----
DM> From: Anton Tagunov [mailto:[EMAIL PROTECTED]]
DM> Sent: Monday, January 28, 2002 4:19 PM
DM> To: Duane Morse
DM> Cc: [EMAIL PROTECTED]
DM> Subject: Re: What does the spec say about how servlet contains handle
DM> static v ariables in the same class for different web apps?


DM> Hello Duane!

DM>> Does the servlet specification say anything about how the servlet
DM> container
DM>> should deal with static variables
DM>> in the same class when used by different web applications?  The
DM> potential
DM>> problem is having common components
DM>> interfere with each other (as far as static variables are concerned)
DM> when
DM>> they are used in different web apps running in the
DM>> same servlet container.

DM> Not a chance :-)

DM> The same .class file loaded by twice by different classloaders
DM> results in two classes differnt from the JVM point of view.
DM> A class in JVM is designated by
DM> - its name
DM> - the classloader that loaded it

DM> So, if file.class has been loaded by two different classloaders
DM> two different classes appear in the JVM. And each has its own
DM> set of static variables.

DM> And all servlet containers provide separate classloaders for
DM> separate webapps.

DM> I guess that if you servlet container
DM> provides dynamic web reloading (f.e. when it detects that
DM> some .jar has changed its creating date to a later time)
DM> then this is implemented by supplying a new class loader
DM> each time the webapp reloads.

DM> (Hence some people get a
DM> funny problem: they define some class, f.e. class A,
DM> put it into a .jar, put the jar into the WEB-INF
DM> of a webapp. When the webapp runs it create an instance
DM> of A, save it as a session attribute. Then they change some .jar
DM> in WEB-INF/lib, the whole webapp gets reloaded.
DM> While the webapp runs it at some moment get this session attribute,
DM> but it is no longer belonging to class with name A, loaded
DM> by the webapp's classloader!
DM> They get an exception when this object to A!)

DM>> Duane Morse, Eldorado Computing Inc., Phoenix, Arizona

DM> Best regards

DM> - Anton
DM> [EMAIL PROTECTED]
DM> [EMAIL PROTECTED]

DM> ___________________________________________________________________________
DM> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
DM> of the message "signoff SERVLET-INTEREST".

DM> Archives: http://archives.java.sun.com/archives/servlet-interest.html
DM> Resources: http://java.sun.com/products/servlet/external-resources.html
DM> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


DM> __________
DM> ��� ��� ������� �� ������ ���� ����? ������ ��� � ������� - http://www.newhost.ru



- Anton
[EMAIL PROTECTED]
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to