This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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, "" 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 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:
subject: can't find properties file problem
It's not a secret anymore!