I have code that is running correctly on a development machine but throws a NullPointerException when installed in a production environment. The line that throws the exception is the following:
MyClass.class.getClassLoader().getResource("").getPath();
So I split this into multiple lines of code to see exactly which call was returning null, like this:
ClassLoader cl = MyClass.class.getClassLoader();
URL url = cl.getResource("");
String path = url.getPath();
Now the url.getPath() call is throwing the NullPointerException, meaning that cl.getResource("") is returning null.
Can anyone tell me how this call can ever return null?