아래 코드는 Tomcat에서 아름답게 작동하지만 getResource (...) 호출은 WebSphere 6.1에서 null을 반환합니다. Thread.currentThread(). getClassLoader() 및 MyClass.class.getClassLoader() - 둘 다 null을 반환합니다.WebSphere 6.1의 클래스 경로에있는 자원의 URL을 올바르게 얻으려면 어떻게해야합니까?
URL url = null;
ClassLoader cl = MyClass.class.getClassLoader();
LOG.info("Using class's 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.");
}
는 ... 그리고 나는 또한
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.");
}
이와 무슨 ... 아니 운이를 시도? 클래스 패스에서 리소스에 대한 URL을 올바르게 얻으려면 어떻게해야합니까?
클래스 변형을 시도했습니다. 불운. 하지만 문제를 해결하는 선도적 인 슬래시에 돈이 있습니다 ... 지금 다시 테스트 해 보겠습니다. 곧 확인하겠습니다 :) – Jared