Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 22047 invoked from network); 5 Jun 2003 20:09:19 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 5 Jun 2003 20:09:19 -0000 Received: (qmail 253 invoked by uid 97); 5 Jun 2003 20:11:35 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 246 invoked from network); 5 Jun 2003 20:11:33 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 5 Jun 2003 20:11:33 -0000 Received: (qmail 19065 invoked by uid 500); 5 Jun 2003 20:08:41 -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 18906 invoked from network); 5 Jun 2003 20:08:39 -0000 Received: from unknown (HELO mustang.mpi.com) (63.244.250.132) by daedalus.apache.org with SMTP; 5 Jun 2003 20:08:39 -0000 Received: from thunderbolt.mpi.com (thunderbolt.mpi.com [199.93.192.55]) by mustang.mpi.com (Switch-2.2.6/Switch-2.2.6) with ESMTP id h55K8eh15891 for ; Thu, 5 Jun 2003 16:08:40 -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 h55K8djn020706 for ; Thu, 5 Jun 2003 16:08:43 -0400 (EDT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C32B9E.3D184730" Subject: RE: [SOLVED]RE: getResourceAsStream cached by Tomcat'sClassloader? Date: Thu, 5 Jun 2003 16:08:32 -0400 Message-ID: <9C5166762F311146951505C6790A9CF8A6E628@US-VS1.corp.mpi.com> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [SOLVED]RE: getResourceAsStream cached by Tomcat'sClassloader? Thread-Index: AcMrmhQ7KhBpfOV7Qligs1ZJg2C/VgAA/c2g 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 ------_=_NextPart_001_01C32B9E.3D184730 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Howdy, Seeing your comment made me think twice, and then test it out... And I= was wrong! The code below works even in a packed .war it seems. (Tomcat 4.1.24, JDK 1.4.1, Solaris 8, autoDeploy=3D"false", unpackWARS=3D"false", test.war attached). Sorry about that -- my mist= ake. Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Larry Meadors [mailto:Larry.Meadors@plumcreek.com] >Sent: Thursday, June 05, 2003 3:38 PM >To: tomcat-user@jakarta.apache.org >Subject: RE: [SOLVED]RE: getResourceAsStream cached by Tomcat'sClassloader? > >Really? I guess I have seen enough right answers from you to not doub= t >it, but I thought that using the URL would work... > >Larry > >>>> Yoav.Shapira@mpi.com 06/05/03 12:37 PM >>> > >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 for >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 wor= ks >>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 hel= p >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 chain. >>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 fact >>that >>the getResourceAsStream is being called in a static method and the >>resulting >>InputStream, which is wrapped in an InputStreamReader, is passed int= o >an >>object that is a static variable in my BaseDAO class. So, because th= e >>reference is at the Class level it might be holding onto it no matte= r >>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 reloadin= g? >> >> >>----- 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 2002. >>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 n= ot >>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.o= rg >>> >>> >> >> >> >> >>--------------------------------------------------------------------= - >>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 >communication, and may contain information that is confidential, >proprietary and/or privileged. This e-mail is intended only for the >individual(s) to whom it is addressed, and may not be saved, copied, >printed, disclosed or used by anyone else. If you are not the(an) >intended recipient, 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 > > > > >---------------------------------------------------------------------= >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. ------_=_NextPart_001_01C32B9E.3D184730 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org ------_=_NextPart_001_01C32B9E.3D184730--