The code below works fine in Tomcat, but calling getResource (...) returns null in WebSphere 6.1. I tried using as Thread.currentThread (). GetClassLoader () and MyClass.class.getClassLoader () - both return null.
URL url = null; ClassLoader cl = MyClass.class.getClassLoader(); LOG.info("Using class classloader."); url = cl.getResource("resources/AConfigFile.xml"); if(url == null) { throw new RuntimeException("The ClassLoader returned null for the URL of the " + "the XML Document. This is definitely not right."); }
... and I also tried it, no luck ...
URL url = null; url = MyClass.class.getResource("resources/AConfigFile.xml"); if(url == null) { throw new RuntimeException("The ClassLoader returned null for the URL of the " + "the XML Document. This is definitely not right."); }
What's up with that? How to get resource url in classpath correctly?
Jared source share