jQuery in Action, 3rd edition
The moose likes Tomcat and the fly likes can't find properties file problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "can Watch "can New topic

can't find properties file problem

Denise Hum

Joined: Oct 09, 2001
Posts: 20
I'm running Tomcat 5.5.9 and I'm trying to load a properties file, "sql.properties" from within my application. I searched the previous threads and tried those suggestions, but it's just not working for me. Here is the code that I am trying to run.

It is finding that inStream is null. I tried putting sql.properties in the WEB-INF/classes directory as well as the directory that this class is in and it's still not finding it. Any ideas? Thanks.
Stian Almaas
Ranch Hand

Joined: Sep 22, 2005
Posts: 37
Try running this:

That should show you the working directory for your server user.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410


Look at the third item on this list for instructions on loading properties files using ServletContext.getResourceAsStream.
Tomcat uses custom classloaders and may not work the way your expecting it to.

The link also shows how to load the properties file as a resourceBundle.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link: http://aspose.com/file-tools
subject: can't find properties file problem
jQuery in Action, 3rd edition