यह पैकेज है कि यह अनुक्रमण होना चाहिए में सही नहीं है,। फिर भी, जब मैं फोनअपाचे फ़ेलिक्स के अंदर चलते समय JAXB मेरे jaxb.index को क्यों नहीं ढूंढ सकता?
JAXBContext jc = JAXBContext.newInstance("my.package.name");
मैं एक JAXBException कह रही है कि
"my.package.name" does not को ObjectFactory.class या jaxb.index
होते हैं, हालांकि यह शामिल है मिल दोनों।
काम करता है, लेकिन काफी मैं क्या चाहते हैं नहीं है क्या,
JAXBContext jc = JAXBContext.newInstance(my.package.name.SomeClass.class);
विभिन्न अन्य लोगों से यह सवाल काफी कुछ मेलिंग सूची और मंचों पर दिखाई देता है लेकिन मालूम होता है जवाब पाने नहीं करता है।
मैं OpenJDK 6 पर इस चल रहा हूँ, इसलिए मैं स्रोत संकुल मिला है और पुस्तकालय में मेरी डिबगर कदम रखा। यह jaxb.properties की तलाश द्वारा शुरू होता है तो प्रणाली संपत्तियों के लिए लग रहा है और या तो लगता है करने में नाकाम रहने, यह com.sun.internal.xml.bind.v2.ContextFactory का उपयोग कर डिफ़ॉल्ट संदर्भ बनाने के लिए कोशिश करता है। वहाँ में, अपवाद (ContextFactor.createContext(String ClassLoader, Map)
अंदर) फेंक दिया जाता है, लेकिन मैं नहीं देख सकते हैं क्या हो रहा है, क्योंकि स्रोत यहाँ नहीं है।
ईटीए:
ContentFactory के लिए स्रोत कोड से परखने के बाद, मैं here पाया, यह शायद कोड का टुकड़ा है कि उद्देश्य के अनुसार कार्य करने में विफल रहता है:
/**
* Look for jaxb.index file in the specified package and load it's contents
*
* @param pkg package name to search in
* @param classLoader ClassLoader to search in
* @return a List of Class objects to load, null if there weren't any
* @throws IOException if there is an error reading the index file
* @throws JAXBException if there are any errors in the index file
*/
private static List<Class> loadIndexedClasses(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
final String resource = pkg.replace('.', '/') + "/jaxb.index";
final InputStream resourceAsStream = classLoader.getResourceAsStream(resource);
if (resourceAsStream == null) {
return null;
}
मेरी previousexperience से, मेरा अनुमान है कि इस OSGi कंटेनर के वर्ग लोड हो रहा है तंत्र है कि इस में चल रहा है के साथ क्या करना है। दुर्भाग्य से, मैं अभी भी एक छोटे से मेरी गहराई यहाँ से बाहर हूँ।
मेरा मतलब है कि अपवाद स्टैक ट्रेस पोस्ट करें। – akarnokd
पोस्ट पहले से थोड़ा लंबा हो रहा है, लेकिन मैंने पहले ही अपवाद की उत्पत्ति को ट्रैक किया है, बस इसे ऊपर पोस्ट किया है। –