ClassLoader getResourceAsStream returns null
If you are working with Maven, add the following lines under BUILD tag. You get this error when you are running the webapp on server but there is no reference to the resources on the server.
So, add this the following into your POM.xml and see the magic.
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>fileName.txt</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>fileName.wsdl</include>
</includes>
</resource>
</resources>
Have Fun.!!!
If it's in the same package use
InputStream is = Driver.class.getResourceAsStream("myconfig.txt");
The way you have it
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("myconfig.txt");
It's looking for the file in the root of the classpath. You could use
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("com/me/myapp/myconfig.txt");
The rules for searching are explained in the javadoc of ClassLoader#getResource(String)
and the javadoc of Class#getResource(String)
.