Thanks for the reply. Yes, I had ensured it (even did a double-check after your mail, everything seems in place). But the problem persists. Everytime, webapp2 calls x.getA(), a null is returned, which shouldn't be the case, since a is a static variable.
I have done another test. What I have done is, open both the webapps in two different windows. Call x.setA() from webapp1, and then call x.getA() from webapp1 as well as webapp2. It's working fine in webapp1, but not in webapp2-returning null. This clearly tells that :: a) Both webapps get two different instances of x.class- pretty ok. b) Each instance has a "different" instance of variable a, which SHOULD NOT BE THE CASE, since a is static. Any lights in a dark tunnel ?? Ajay Garg Konstantin Kolinko wrote: > > Make sure, that you do not have a copy of x.class in WEB-INF/classes > or WEB-INF/lib/*.jar of any of your web applications. Those take > precedence over shared or common classes. > > See > http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html > for details. > > > 2008/7/17 java_is_everything <[EMAIL PROTECTED]>: >> >> I am sorry. The methods setA() and getA() are static, Rest everything >> remains >> same. >> >> Regards >> Ajay Garg >> >> >> >> java_is_everything wrote: >>> >>> Hi all. >>> >>> I have placed two applications in the webapps folder, and calling a >>> class, >>> say 'x.java' placed in tomcat's shared folder. x.java is of the >>> following >>> config : >>> >>> >>> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// >>> public class x >>> { >>> public static int a; >>> >>> static >>> { >>> System.out.println("Static things initializing !!!!!!"); >>> } >>> >>> public void setA(int aa) >>> { >>> a = aa; >>> } >>> >>> public int getA() >>> { >>> return a; >>> } >>> } >>> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// >>> >>> >>> Now, when i call x.setA(123) from webapp1, an instance of x.java will be >>> loaded (obviously, since this is the first time), and the method be >>> called >>> appropriately. Now, if I now call x,getA() from webapp2, I expect to get >>> the value 123. But I don't .. :-( Instead I get a null as returned >>> value. >>> >>> >>> Moreover, I also see that static initializer is called both times !!!!! >>> >>> Any ideas as to why ??? (I use Tomcat 5.5.26). >>> >>> >>> Looking forward to replies. >>> Ajay Garg >>> >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Doubt-on-lifecycle-of-a-class-in-%22shared%22-folder-tp18502300p18502310.html >> Sent from the Tomcat - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Doubt-on-lifecycle-of-a-class-in-%22shared%22-folder-tp18502300p18504589.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]