• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getResourceAsStream() +NullPointerException

 
Elizabath Lima
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

I'm having a strange problem.

Properties props = new Properties(); props.load(this.getClass().getResourceAsStream("/myapp.properties"));
driver=props.getProperty("dbdriver");
url = props.getProperty("dburl");
userName = props.getProperty("dbuser");
password = props.getProperty("dbpass");

this gives the following exception in tomcat. I placed the properties file directly under 'myapp' directory which s under webapp. How i can give path of propfile?

java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:365)
at java.util.Properties.load(Properties.java:293)
at org.nmn.DBConn.getConnection(DBConn.java:23)

Thanks in advance
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try dropping it on the WEB-INF/classes directory so that it can be found on the application classpath
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic