Re: [Fwd: static fields suddenly started sharing]
Thanks for the suggestions, guys. This has been a tricky one to work through but I think I have the answer - kind of. A number of people responded with help for which I am grateful (think: 2am and I'm all alone and it has to be fixed by morning, it is so nice to see a helpful message come through). What I thought I was seeing was the static fields suddenly being shared between two apps. I got reports of errors from the live site (to which I have no direct access) and I reproduced a similar problem on my dev environment. When I looked deeper I found the statics were shared between the two apps so I concluded the same thing was happening on the live site. It certainly explained what they reported from the live site. But two different things were happening. On my dev system I run tomcat under eclipse, using the plugin. It has always worked fine. I recently started using ivy in my eclipse projects and that seems to do something odd to the class loader which is what I was seeing. Filip Hanlik suggested I use this code to see how the classloader was loading: ClassLoader parent = this.getClass().getClassLoader(); while ( parent != null ) { if (parent instance of URLClassLoader) { //print URLs using getURLS() method parent = parent.getParent(); } I put a variation of this into my contextlisterner classes and it showed this (edited for brevity) 10-05-2007 20:45:58 parent=org.apache.catalina.loader.WebappClassLoader 10-05-2007 20:45:58 file:/C:/projects/Hermes/HermesAdmin/WEB-INF/classes/ 10-05-2007 20:45:58 file:/C:/projects/Hermes/HermesAdmin/WEB-INF/lib/HermesServer.jar 10-05-2007 20:45:58 file:/C:/projects/Hermes/HermesAdmin/WEB-INF/lib/MaduraApplet-2.0.jar 10-05-2007 20:45:58 file:/C:/projects/Hermes/HermesAdmin/WEB-INF/lib/MaduraServer-2.0.jar This is the relevant library 10-05-2007 20:45:58 parent=org.apache.catalina.loader.StandardClassLoader 10-05-2007 20:45:58 file:C:/Program Files/Apache Group/Tomcat 4.1/shared/classes/ ... 10-05-2007 20:45:58 parent=org.apache.catalina.loader.StandardClassLoader 10-05-2007 20:45:58 file:C:/Program Files/Apache Group/Tomcat 4.1/common/classes/ ... 10-05-2007 20:45:58 parent=sun.misc.Launcher$AppClassLoader 10-05-2007 20:45:58 file:/C:/projects/Hermes/HermesServer/classes/ 10-05-2007 20:45:58 file:/C:/eclipsev32/plugins/org.junit_3.8.1/junit.jar 10-05-2007 20:45:58 file:/C:/Program%20Files/Apache%20Group/Tomcat%204.1/common/lib/servlet.jar ... 10-05-2007 20:45:58 file:/C:/projects/ivy_resources_madura/ivy_cache/senanque/Madura/jars/MaduraServer-2.0.jar << and here it is again !! 10-05-2007 20:45:58 file:/C:/projects/ivy_resources_madura/ivy_cache/senanque/Madura/jars/MaduraApplet-2.0.jar ... 10-05-2007 20:45:58 file:/C:/projects/ivy_resources_madura/ivy_cache/apache/xerces/jars/xerces-2.0.2.jar 10-05-2007 20:45:58 file:/C:/Program%20Files/Apache%20Group/Tomcat%204.1/bin/bootstrap.jar 10-05-2007 20:45:58 file:/C:/j2sdk1.4.2_11/lib/tools.jar 10-05-2007 20:45:58 parent=sun.misc.Launcher$ExtClassLoader 10-05-2007 20:45:58 file:/C:/j2sdk1.4.2_11/jre/lib/ext/dnsns.jar 10-05-2007 20:45:58 file:/C:/j2sdk1.4.2_11/jre/lib/ext/ldapsec.jar 10-05-2007 20:45:58 file:/C:/j2sdk1.4.2_11/jre/lib/ext/localedata.jar 10-05-2007 20:45:58 file:/C:/j2sdk1.4.2_11/jre/lib/ext/sunjce_provider.jar So the problem is that the ivy libraries are loading too early. I don't see a way to control this from the eclipse UI but it is no problem to test the apps one at a time. This might help someone else though. I tried it running stand-alone on the tomcat 5.5 system on my dev machine and thought I reproduced the error but I cannot now so I will put that down to late night brain fade. The live site has mysteriously righted itself. The only thing I know they did there was to clear the app directories in webapps and restart the server. It is just possible that they were doing something ridiculous and not telling me, they aren't very used to tomcat. The most likely scenario was that they had managed to get two instances of it running and the phantom application was locking the real one. I'm getting too specific to my app here, which is not useful, so I'll stop. Anyway, thanks again for the help. I've mentioned Filip but the responses from Christopher Schultz and Johnny Kewl were very welcome too. Oh, and Christopher asked which library I was using. It isn't one you'd know, a home grown framework used for internal projects. Regards Roger - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Fwd: static fields suddenly started sharing]
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Roger, Roger Parkinson wrote: > I have two different applications and they both make use of a common > jar library. The common library has several static fields. [snip] > I am trying to figure out what I changed to make this happen because > it is causing me problems. The changes I made were a restructure, > shifting things around into different folders in my eclipse project, > but the same jar files are in WEB-INF/lib as there always were. That's odd. If you really have those JAR files in WEB-INF/lib, then they /should/ be in different ClassLoaders and therefore has their own webapp-private static fields. It is possible that you also added the library in question to the server/lib directory at some point? > Can anyone suggest where I should be looking? I'm sure you have already read the Tomcat Class Loader HOW-TO (http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html), but I'll mention it just in case. * WEB-INF/lib should be private to the app * TOMCAT_HOME/shared/lib should truly be shared (unified static) * TOMCAT_HOME/common/lib should truly be shared (unified static) but Tomcat itself can access the library, too > I'm wondering if I am managing to call something I shouldn't too > early in the application initialisation. Probably not. If you want a wall between the apps, then order-of-initialization shouldn't be a problem. Your webapps should be entirely separate. > Each of the apps has a context listener that does some stuff on > startup of the app (including initialising some statics), but they > haven't changed since it was working. I still have the older > structure and it still works, and I can't see any relevant changes, Are you moving from TC 4.1 to TC 5.5? I believe that the class-loading rules didn't change from 4.1->5.0->5.5, but it's possible that there's some kind of bug in 4.1 that was preserved for some reason while 5.0 and 5.5 work "properly". Someone else on the list will have to comment on that. You should look for all relevant copies of that JAR file to determine what's happening. Let us know where you can find copies (if you can) outside of the WEB-INF/lib directories of your various webapps. Just out of curiosity, which library are we talking about? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGP2GX9CaO5/Lv0PARArB9AKCGHIgiyaqDcoEclgbtI+d8RY4JywCbBB6J Gq+XPloztCr73l9MBC8Hzh8= =mmDV -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Fwd: static fields suddenly started sharing]
Roger Parkinson wrote: I have two different applications and they both make use of a common jar library. The common library has several static fields. Up until last week the static fields in one application never saw the static fields in the other but I changed something and suddenly they do. All the advice I've found through searching the web suggests this cannot happen because the two apps use different class loaders. But it definitely is happening. I'm getting it on Tomcat 4.1 and 5.5 (my two live platforms). I am trying to figure out what I changed to make this happen because it is causing me problems. The changes I made were a restructure, shifting things around into different folders in my eclipse project, but the same jar files are in WEB-INF/lib as there always were. Can anyone suggest where I should be looking? I'm wondering if I am managing to call something I shouldn't too early in the application initialisation. Each of the apps has a context listener that does some stuff on startup of the app (including initialising some statics), but they haven't changed since it was working. I still have the older structure and it still works, and I can't see any relevant changes, you sure you haven't added WEB-INF/lib to a classpath in a startup script or done something else funky like that. what you could do, is to create a little script that does ClassLoader parent = this.getClass().getClassLoader(); while ( parent != null ) { if (parent instance of URLClassLoader) { //print URLs using getURLS() method } parent = parent.getParent(); } Filip Thanks for any help Roger - 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]
[Fwd: static fields suddenly started sharing]
I have two different applications and they both make use of a common jar library. The common library has several static fields. Up until last week the static fields in one application never saw the static fields in the other but I changed something and suddenly they do. All the advice I've found through searching the web suggests this cannot happen because the two apps use different class loaders. But it definitely is happening. I'm getting it on Tomcat 4.1 and 5.5 (my two live platforms). I am trying to figure out what I changed to make this happen because it is causing me problems. The changes I made were a restructure, shifting things around into different folders in my eclipse project, but the same jar files are in WEB-INF/lib as there always were. Can anyone suggest where I should be looking? I'm wondering if I am managing to call something I shouldn't too early in the application initialisation. Each of the apps has a context listener that does some stuff on startup of the app (including initialising some statics), but they haven't changed since it was working. I still have the older structure and it still works, and I can't see any relevant changes, Thanks for any help Roger - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]