Junit + getResourceAsStream Returning Null

It's not finding the resource on the classpath. If you are using junit and maven make sure the resources are copied on the target/test-classes by adding <include> file directive on <testResource> section

You can also find out the location of your class in the file system by using

this.getClass().getResource(".")

and checking to see if the resource is there


getResourceAsStream() is using the CLASSPATH, and as such it will load from wherever your classes are, not your source files.

I suspect you need to copy your XML to the same directory as your .class file.