packed WARs occur all the time, especially if they are inside an EAR file Filip
> -----Original Message----- > From: Brandon Goodin [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 05, 2003 11:50 AM > To: Tomcat Users List > Subject: RE: [SOLVED]RE: getResourceAsStream cached by Tomcat's > Classloader? > > > Dang it! I knew it was too good to be true. Well, it works just > fine for me. > I do not deal with WARs. Anywyas, why would anyone want to run from a > "packed" WAR anyways (instead of unpacked)? I'm not being sarcastic. I am > just trying to think of an instance where it makes sense. > > Brandon Goodin > > -----Original Message----- > From: Shapira, Yoav [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 05, 2003 12:37 PM > To: Tomcat Users List > Subject: RE: [SOLVED]RE: getResourceAsStream cached by Tomcat's > Classloader? > > > > 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:[EMAIL PROTECTED] > >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 = "my-config.xml"; > > > >ClassLoader loader = > > Thread.currentThread().getContextClassLoader(); > > > >URL url = > > loader.getResource(resource); > > > >Reader reader = > > 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:[EMAIL PROTECTED] > >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:[EMAIL PROTECTED] > >Sent: Thursday, June 05, 2003 11:12 AM > >To: [EMAIL PROTECTED] > >Subject: RE: getResourceAsStream cached by Tomcat's Classloader? > > > > > >I think you are right, but I always use Thread method because it works > >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 > > > >>>> [EMAIL PROTECTED] 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:[EMAIL PROTECTED] > >Sent: Thursday, June 05, 2003 9:45 AM > >To: [EMAIL PROTECTED] > >Subject: RE: getResourceAsStream cached by Tomcat's Classloader? > > > > > >Are the static variables transient? If not, the session manager may > >persist them on a reload. > > > >>>> [EMAIL PROTECTED] 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 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:[EMAIL PROTECTED] > >Sent: Thursday, June 05, 2003 8:58 AM > >To: [EMAIL PROTECTED] > >Cc: [EMAIL PROTECTED] > >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 > > > >>>> [EMAIL PROTECTED] 06/05/03 8:04 AM >>> > >Yes, it is closed. > > > >Brandon Goodin > > > >-----Original Message----- > >From: Dominic Parry [mailto:[EMAIL PROTECTED] > >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" <[EMAIL PROTECTED]> > >To: <[EMAIL PROTECTED]> > >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 not > >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: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
