File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes getResourceAsStream() +NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getResourceAsStream() +NullPointerException" Watch "getResourceAsStream() +NullPointerException" New topic

getResourceAsStream() +NullPointerException

Elizabath Lima
Ranch Hand

Joined: Nov 23, 2005
Posts: 32

I'm having a strange problem.

Properties props = new Properties(); props.load(this.getClass().getResourceAsStream("/"));
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?

at java.util.Properties$LineReader.readLine(
at java.util.Properties.load(
at org.nmn.DBConn.getConnection(

Thanks in advance
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Try dropping it on the WEB-INF/classes directory so that it can be found on the application classpath
I agree. Here's the link:
subject: getResourceAsStream() +NullPointerException
It's not a secret anymore!