Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 41676 invoked from network); 5 Jun 2003 18:38:12 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 5 Jun 2003 18:38:12 -0000 Received: (qmail 27930 invoked by uid 97); 5 Jun 2003 18:40:29 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 27923 invoked from network); 5 Jun 2003 18:40:29 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 5 Jun 2003 18:40:29 -0000 Received: (qmail 39864 invoked by uid 500); 5 Jun 2003 18:37:48 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 39848 invoked from network); 5 Jun 2003 18:37:47 -0000 Received: from unknown (HELO warhawk.mpi.com) (63.244.250.133) by daedalus.apache.org with SMTP; 5 Jun 2003 18:37:47 -0000 Received: from thunderbolt.mpi.com (thunderbolt.mpi.com [199.93.192.55]) by warhawk.mpi.com (Switch-2.2.6/Switch-2.2.6) with ESMTP id h55Ibl617410 for ; Thu, 5 Jun 2003 14:37:48 -0400 (EDT) Received: from US-VS1.corp.mpi.com (us-be2.corp.mpi.com [199.93.195.21]) by thunderbolt.mpi.com (Switch-3.0.4/Switch-3.0.0) with ESMTP id h55Ibijn000124 for ; Thu, 5 Jun 2003 14:37:49 -0400 (EDT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [SOLVED]RE: getResourceAsStream cached by Tomcat's Classloader? Date: Thu, 5 Jun 2003 14:37:15 -0400 Message-ID: <9C5166762F311146951505C6790A9CF8A6E623@US-VS1.corp.mpi.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SOLVED]RE: getResourceAsStream cached by Tomcat's Classloader? Thread-Index: AcMrjNe1q3trW0+1RA+lhVe1QFl95QABFKvA From: "Shapira, Yoav" To: "Tomcat Users List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Howdy, Please note your approach will fail when running from a packed .war file, as the new File(..) will throw an exception. This might be OK f= or your environment, but is important to keep in mind for portability. Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Brandon Goodin [mailto:mail@phase.ws] >Sent: Thursday, June 05, 2003 2:08 PM >To: Tomcat Users List >Subject: [SOLVED]RE: getResourceAsStream cached by Tomcat's Classloader? > >Well, here is how I solved my problem: > >-- code start -- > >String resource =3D "my-config.xml"; > >ClassLoader loader =3D > Thread.currentThread().getContextClassLoader(); > >URL url =3D > loader.getResource(resource); > >Reader reader =3D > new FileReader( > new File( > url.getFile())); > >-- code stop -- > >Directly calling the getResourceAsStream failed to produce a copy of the >altered config. Is this a bug? > >Brandon Goodin > >-----Original Message----- >From: Brandon Goodin [mailto:mail@phase.ws] >Sent: Thursday, June 05, 2003 11:23 AM >To: Tomcat Users List >Subject: RE: getResourceAsStream cached by Tomcat's Classloader? > > >Aaaah. A man after my own heart! Keep it simple. > >Brandon Goodin > >-----Original Message----- >From: Larry Meadors [mailto:Larry.Meadors@plumcreek.com] >Sent: Thursday, June 05, 2003 11:12 AM >To: tomcat-user@jakarta.apache.org >Subject: RE: getResourceAsStream cached by Tomcat's Classloader? > > >I think you are right, but I always use Thread method because it work= s >even in a static method - you do not need 'this' for it to work. > >I prefer having one way to do this instead of two - that way I can think >less about how to get the CL, and more about the problem it will help= me >solve (and I am lazy). ;-) > >Larry > >>>> mail@phase.ws 06/05/03 10:58 AM >>> >>"Are you using this code to get a classloader? >>Thread.currentThread().getContextClassLoader(); >>If not, you are not getting tomcat's you are getting the system one.= " > >Are you sure this is true? > >A ClassLoader can have a parent ClassLoader. But, a class does not >maintain >a single copy across all ClassLoader contexts. Therefore, the Class type >can >exist in multiple ClassLoaders. So a Class has a reference to it's >ClassLoader context when it is created. When the >this.getClass().getClassLoader() is called it calls the context that the >class was loaded in. I think you would have to specifically call the >getParent() of the Classloader in order to go up the Classloader chai= n. >In >this situation I think Thread.currentThread().getContextClassLoader()= >and >this.getClass().getClassLoader() will accomplish the same thing. > >Brandon Goodin > >-----Original Message----- >From: Larry Meadors [mailto:Larry.Meadors@plumcreek.com] >Sent: Thursday, June 05, 2003 9:45 AM >To: tomcat-user@jakarta.apache.org >Subject: RE: getResourceAsStream cached by Tomcat's Classloader? > > >Are the static variables transient? If not, the session manager may >persist them on a reload. > >>>> mail@phase.ws 06/05/03 9:41 AM >>> >I have tried it both ways. My notion is that it has to do with the fa= ct >that >the getResourceAsStream is being called in a static method and the >resulting >InputStream, which is wrapped in an InputStreamReader, is passed into= an >object that is a static variable in my BaseDAO class. So, because the= >reference is at the Class level it might be holding onto it no matter= >what I >do. If you want I can show you the code. I have some ideas. But, I'm not >sure if they will work. > >Brandon Goodin > >-----Original Message----- >From: Larry Meadors [mailto:Larry.Meadors@plumcreek.com] >Sent: Thursday, June 05, 2003 8:58 AM >To: tomcat-user@jakarta.apache.org >Cc: mail@phase.ws >Subject: RE: getResourceAsStream cached by Tomcat's Classloader? > > >Hey Brandon, > >Are you using this code to get a classloader? > >Thread.currentThread().getContextClassLoader(); > >If not, you are not getting tomcat's you are getting the system one. > >Larry > >>>> mail@phase.ws 06/05/03 8:04 AM >>> >Yes, it is closed. > >Brandon Goodin > >-----Original Message----- >From: Dominic Parry [mailto:dom@rucus.ru.ac.za] >Sent: Thursday, June 05, 2003 7:44 AM >To: Tomcat Users List >Subject: Re: getResourceAsStream cached by Tomcat's Classloader? > > >did you close the original stream before making changes and reloading= ? > > >----- Original Message ----- >From: "Brandon Goodin" >To: >Sent: Thursday, June 05, 2003 3:45 PM >Subject: getResourceAsStream cached by Tomcat's Classloader? > > >> I saw a question similar to this asked in the Archives early in 200= 2. >I >> didn't see a response to it. So, I hope there is an answer. >> >> I have a generic config file that is an xml file. We'll call it >> my-config.xml. >> >> When I load my-config.xml using >> Classloader.getResourceAsStream("my-config.xml") everything works >great. >> However, when I make a change to that file and again call >> Classloader.getResourceAsStream("my-config.xml") the changes are no= t >picked >> up and the same initial resource is returned. How do I get the >Classloader >> to reconginze the resource changes? I'm using Tomcat 4.1.18. >> >> >> Brandon Goodin >> >> >> -------------------------------------------------------------------= -- >> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >> For additional commands, e-mail: tomcat-user-help@jakarta.apache.or= g >> >> > > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org This e-mail, including any attachments, is a confidential business com= munication, and may contain information that is confidential, propriet= ary and/or privileged. This e-mail is intended only for the individua= l(s) to whom it is addressed, and may not be saved, copied, printed, d= isclosed or used by anyone else. If you are not the(an) intended reci= pient, please immediately delete this e-mail from your computer system= and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org