के परिणामस्वरूप पुनरावृत्ति करते समय अजीब एनपीई मुझे लगता है कि निम्नलिखित कोड सुरक्षित है, फिर भी मुझे hasMoreElements()
का आह्वान करते समय एनपीई मिल रहा है। कोई अंदाज़ा कि क्या गलत हो सकता है?क्लासलोडर.getResources()
मुझे यह जोड़ना चाहिए कि मैं जावा, 64 बिट पर जावा 1.7.0_55-b13 का उपयोग कर रहा हूं।
final List<URL> urls = new ArrayList<URL>();
final String plUri = "META-INF/plugin.xml";
Enumeration<URL> urlsEn =
Thread.currentThread().getContextClassLoader().getResources(pluginsUri);
if (urlsEn != null) {
while (urlsEn.hasMoreElements()) { // NPE happens here
final URL u = urlsEn.nextElement();
urls.add(u);
}
}
स्टैक ट्रेस:
java.lang.NullPointerException
at sun.misc.MetaIndex.mayContain(MetaIndex.java:243)
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:830)
at sun.misc.URLClassPath$2.next(URLClassPath.java:273)
at sun.misc.URLClassPath$2.hasMoreElements(URLClassPath.java:283)
at java.lang.ClassLoader$2.hasMoreElements(ClassLoader.java:1322)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
at com.github.jochen.afw.core.guice.GuiceComponentFactoryBuilder.getComponentUrls(GuiceComponentFactoryBuilder.java:256)
at com.github.jochen.afw.core.guice.GuiceComponentFactoryBuilder.build(GuiceComponentFactoryBuilder.java:160)
at com.github.jochen.afw.core.guice.GuiceComponentFactoryBuilderTest.testSuccessfullConfiguration(GuiceComponentFactoryBuilderTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....
में तय किया गया है समस्या नहीं है कि 'urlsEn' मान शून्य होगा - एनपीई ढेर नीचे फेंक दिया जाता है तो यह एक तरह लग रहा है बग .. – assylias
आपके थ्रेड संदर्भ वर्ग लोडर का प्रकार क्या है? –