Huh. Here's a test with TC 5.0.27, JDK 1.4.2_05, and WinXP:

loadProps.jsp:
--------------
<%@ page contentType="text/plain" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%
String fileName = "foo.properties";
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream in = cl.getResourceAsStream(fileName);
Properties props = new Properties();
props.load(in);
out.print(props);
%>

With "foo.properties" located in WEB-INF/classes, the page outputs:

{A=1, C=3, B=2}

Have you done anything to TC like create a custom Context for the app? Are you
sure target.getConfigurationName() is really returning what you expect (e.g. no
leading spaces, etc.)?

Quoting "Rosenberg, Leon" <[EMAIL PROTECTED]>:

> Yep, exactly
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Kris Schneider [mailto:[EMAIL PROTECTED]
> > Gesendet: Mittwoch, 21. Juli 2004 17:30
> > An: Struts Users Mailing List
> > Betreff: Re: AW: AW: OT: Problems with classpath under tomcat 5
> > 
> > Does "filename" evaluate to something like "foo.properties" (no other path
> > info)
> > and is that file located in WEB-INF/classes?
> > 
> > Quoting "Rosenberg, Leon" <[EMAIL PROTECTED]>:
> > 
> > > Thanx, but it doesn't work either.
> > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Kris Schneider [mailto:[EMAIL PROTECTED]
> > > > Gesendet: Mittwoch, 21. Juli 2004 16:54
> > > > An: Struts Users Mailing List
> > > > Betreff: Re: AW: OT: Problems with classpath under tomcat 5
> > > >
> > > > ..
> > > > String fileName = target.getConfigurationName() + ".properties";
> > > > ClassLoader cl = Thread.currentThread().getContextClassLoader();
> > > > InputStream in = cl.getResourceAsStream(fileName);
> > > > Properties props = new Properties();
> > > > props.load(in);
> > > > ..
> > > >
> > > > Quoting "Rosenberg, Leon" <[EMAIL PROTECTED]>:
> > > >
> > > > >
> > > > >
> > > > > > -----Ursprüngliche Nachricht-----
> > > > > > Von: Peng Tuck Kwok [mailto:[EMAIL PROTECTED]
> > > > > > Gesendet: Mittwoch, 21. Juli 2004 16:10
> > > > > > An: Struts Users Mailing List
> > > > > > Betreff: Re: OT: Problems with classpath under tomcat 5
> > > > > >
> > > > > > Are you sure if it is not looking your properties file in the
> > > > > > classpath of the webapp ?
> > > > >
> > > > > Yes, because it would find them there.
> > > > >
> > > > > > When you say everything works fine until tomcat 5 is used , does
> > the
> > > > > > console print out any error ? Also how do you know it is searching
> > in
> > > > > > shared classes ?
> > > > >
> > > > > Yes, the console prints out our debug output:
> > > > >
> > > > > xyz.properties doesn't exist, skipping update for [EMAIL PROTECTED]
> > > > >
> > > > > if you read the code, you'll find that it's also trying to locate
> > the
> > > > '.'
> > > > > directory. In all other environments it's webapps/mywebapp/WEB-
> > > > INF/classes
> > > > > in tomcat5 it's .../common/classes (which is one of the pathes
> > according
> > > > to
> > > > > tomcat5 class loader faq). (Sorry, I wrote shared/classes in my
> > first
> > > > mail,
> > > > > it was common/classes, but it doesn't really matter, because both
> > aren't
> > > > the
> > > > > right ones :-)
> > > > >
> > > > > Regards
> > > > > Leon
> > > > >
> > > > >
> > > > > >
> > > > > > On Wed, 21 Jul 2004 15:45:01 +0200, Rosenberg, Leon
> > > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > it's a bit OT but maybe some of you had a similar problem
> > shortly
> > > > and
> > > > > > > can help.
> > > > > > >
> > > > > > > We have a configuration component which configures other
> > components
> > > > of
> > > > > > > the application out of property files. The property files lies
> > in
> > > > the
> > > > > > > 'classes' directory of the application. Everything works fine
> > until
> > > > we
> > > > > > > use tomcat 5 (5.0.19).
> > > > > > >
> > > > > > > In tomcat 5 the ClassLoader doesn't search for our property
> > files in
> > > > > > > webapps/mywebapp/WEB-INF/classes. Instead it seems to search in
> > > > > > > shared/classes which imho should be done after the private
> > webapp
> > > > > > > classpath has bin searched through.
> > > > > > >
> > > > > > > As I said before it works fine with standalone applications and
> > with
> > > > > > > resin.
> > > > > > >
> > > > > > > Any ideas?
> > > > > > >
> > > > > > > Regards
> > > > > > >
> > > > > > > Leon
> > > > > > >
> > > > > > > P.S.
> > > > > > >
> > > > > > > The files are there and we have the rights to read them.
> > > > > > >
> > > > > > > P. P.S. the code:
> > > > > > >
> > > > > > >       private void updateConfigurable(IConfigurable target,
> > boolean
> > > > > > > dontcheck){
> > > > > > >
> > > > > > >             String fileName =
> > > > > > > target.getConfigurationName()+".properties";
> > > > > > >
> > > > > > >             log.debug("Checking for "+"/"+fileName);
> > > > > > >
> > > > > > >             log.debug("Approx. checking in
> > > > > > > "+target.getClass().getResource("/."));
> > > > > > >
> > > > > > >             URL u = target.getClass().getResource("/"+fileName);
> > > > > > >
> > > > > > >             if (u==null){
> > > > > > >
> > > > > > >                   log.error(fileName+" doesn't exist, skipping
> > > > update
> > > > > > > for "+target);
> > > > > > >
> > > > > > >                   return;
> > > > > > >
> > > > > > >             }
> > > > > > >
> > > > > > >             if (!dontcheck){
> > > > > > >
> > > > > > >                   log.debug("Checking "+target);
> > > > > > >
> > > > > > >                   File f = new File(u.getFile());
> > > > > > >
> > > > > > >                   long lastModified = f.lastModified();
> > > > > > >
> > > > > > >                   long timestamp = getTimestamp(target);
> > > > > > >
> > > > > > >                   if (lastModified<timestamp)
> > > > > > >
> > > > > > >                         return;
> > > > > > >
> > > > > > >                   log.debug("filename has been updated.");
> > > > > > >
> > > > > > >             }
> > > > > > >
> > > > > > >             log.debug("updating "+target);
> > > > > > >
> > > > > > >             try{
> > > > > > >
> > > > > > >                   Properties p = new Properties();
> > > > > > >
> > > > > > > p.load(target.getClass().getResourceAsStream("/"+fileName));
> > > > > > >
> > > > > > >                   target.notifyConfigurationStarted();
> > > > > > >
> > > > > > >                   Enumeration keys = p.keys();
> > > > > > >
> > > > > > >                   while(keys.hasMoreElements()){
> > > > > > >
> > > > > > >                         String key = (String)keys.nextElement();
> > > > > > >
> > > > > > >                         String value = p.getProperty(key);
> > > > > > >
> > > > > > >                         target.setProperty(key, value);
> > > > > > >
> > > > > > >                   }
> > > > > > >
> > > > > > >                   target.notifyConfigurationFinished();
> > > > > > >
> > > > > > >                   setTimestamp(target);
> > > > > > >
> > > > > > >             }catch(Exception e){
> > > > > > >
> > > > > > >                   log.error("updateConfigurable", e);
> > > > > > >
> > > > > > >             }
> > > > > > >
> > > > > > >       }
> > > >
> > > > --
> > > > Kris Schneider <mailto:[EMAIL PROTECTED]>
> > > > D.O.Tech       <http://www.dotech.com/>
> > 
> > --
> > Kris Schneider <mailto:[EMAIL PROTECTED]>
> > D.O.Tech       <http://www.dotech.com/>

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to