• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't find properties file problem

 
Denise Hum
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try running this:



That should show you the working directory for your server user.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Denise,

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.

http://wiki.apache.org/jakarta-tomcat/HowTo
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic