tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Problem Reading Property files
Date Wed, 27 May 2009 13:49:40 GMT
Hash: SHA1


On 5/26/2009 10:43 PM, john S wrote:
> Thanks for your response, Actually we dont have the source code for that
> because it is very old code, but i m using decompiler in which i can get
> some information.


> this.m_im.gatherProperties(localProcessorGroup);-----------this is where it
> is calling the property files.*

(Note that localProcessorGroup is not declared in your code snippet.


> public void gatherProperties(ProcessorGroup paramProcessorGroup)*
> {
> Object localObject;
> this.m_props.clear();
> String str1 = this.m_servlet.getInitParameter(*"loan.dir"*);
> if (str1 == null) {
> str1 = System.getProperty("server.root", System.getProperty("user.dir",
> "."));
> }
> this.m_props.put("loan.dir", str1);
> String str2 = this.m_servlet.getInitParameter("abc.log");
> setLogFile(str2);

The code for setLogFile might be useful. Oh, and the stack trace of the
original exception.

> try
> {
> String str3 = this.m_servlet.getInitParameter("abc.props");
> if (str3 == null)
> str3 = "abc.props";
> localObject = str1 + File.separator + str3;
>"Reading properties from file: " + ((String)localObject));

What does this line of code print to the log file? Or, does nothing
print because the log file has not been correctly configured?

*Sigh*... why can't people use standard logging facilities instead of
using their own?

> Utils.loadProperties(this.m_props, new BufferedInputStream(new
> FileInputStream((String)localObject)));

Yeah, this really should be changed to getResourceAsStream instead of
using a FileInputStream, though since you don't have the original code
it might not be a good idea to mess around with it.

> }
> catch (IOException localIOException) {
> *"NON FATAL WARNING: Could not read props file",
> localIOException);--while running i m getting this error
> *}

Do you get a stack trace along with the error?

> this.m_rroots =
> StringUtils.getPathsFromList(this.m_props.getProperty("resource.path",
> "/com/loan/resources/:/"));

This could be a problem: the use of a forward-slash on a DOS/Windows
filesystem may not get you the desired results. In other code above,
File.separator (and File.pathSeparator) was correctly used so that it
would work on any platform. /This/ line of code uses / and : without
regard for the platform, and is likely to confuse Windows. On the other
hand, nobody here knows what getPathsFromList will do.

> clearAllPGs();
> }
> =================================================================
> the above is the servlet class and the method which is using to read the
> property files from root directory in Unix.
> ie*../opt/mywebapp/loan/abc.props,abc.log*
> loan is the directory in which two property files are placed.

If the files are really in /opt/mywebapp/loan/abc.props, then you did
you tell web.xml that they were in [path to webapp]/WEB-INF/config? Just
tell your servlet where the files really are!

> i just want to where to place property files in tomcat so that its going to
> read the property files.

Then you need to move them.

> Right now, i placing it in the

If you are using /WEB-INF/LOAN/abc.props then you need to use
<param-value>/WEB-INF/LOAN/abc.props</param-value> instead of

> Its giving me errors such as FILENOTFOUNDEXCEPTION or cannot read the
> property files.

The path of the file it's trying to read would be immensely helpful. Can
you post a full stack trace please?

> The main problem is ...I donot have the complete source code. while
> decompiling i m not able view complete source code.

You should be able to view the complete, decompiled source code...

- -chris
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message