2012-04-03 27 views
17

ऐसा प्रतीत होता है कि मैंने पहले से ही इसे पहले ही किया है, लेकिन मुझे काम करने के लिए मैंने जो किया है उसका कोई संदर्भ नहीं मिल रहा है।एक विशेष जेएक्सबी कार्यान्वयन कैसे निर्दिष्ट करें?

मेरे पास एक वेब एप्लिकेशन है जिसमें मैं अपने वेब सर्वर/जेआर द्वारा प्रदान किए गए एक से अलग जेएक्सबी कार्यान्वयन निर्दिष्ट करना चाहता हूं। मैंने मैवेन से उपयुक्त आर्टिफैक्ट डाउनलोड किया, और देखा कि जार मेरे युद्ध में ठीक तरह से पैक किया गया है, हालांकि, जब मैं अपना वेब ऐप शुरू करता हूं, तो मुझे लगता है कि यह अभी भी बंडल जेआरई कार्यान्वयन का उपयोग कर रहा है।

मैं अस्पष्ट रूप से एक प्रॉपर्टी फ़ाइल के बारे में कुछ याद रखता हूं जिसे मैं कॉन्फ़िगर कर सकता हूं, लेकिन इसे कॉन्फ़िगर करने की आवश्यकता के संदर्भ में कोई संदर्भ नहीं मिल रहा है। इसके अलावा, यदि मैं जिस कार्यान्वयन का उपयोग करना चाहता हूं वह वही है (केवल एक नया संस्करण), कक्षा के नाम जेआरई में पैक किए गए समान होंगे। मैं कैसे निर्दिष्ट कर सकता हूं कि मैं अपने युद्ध में बंडल किए गए लोगों का उपयोग करना चाहता हूं?

संपादित

मैं वर्तमान में ओरेकल JDK 1.6_0_27, JAXB आरआई कि JRE (मुझे लगता है कि यह v2.1 है) के साथ आता है के साथ, JBoss 7.0.2 पर चल रहा हूँ। मैं जेएक्सबी आरआई 2.2.5 (एमवीआर रिपोजिटरी पर पाया गया) में अपग्रेड करने की कोशिश कर रहा हूं।

मैं एक छोटे से अधिक आज सुबह खुदाई किया है किया है, और अपने लॉग में एक अजीब त्रुटि संदेश देखा:

09:43:18,325 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jaxb-api.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference. 
09:43:18,325 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry activation.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference. 
09:43:18,326 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jsr173_1.0_api.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference. 
09:43:18,326 WARN [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jaxb1-impl.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar" does not point to a valid jar for a Class-Path reference. 

कौन सा मैं बहुत ही अजीब पाया। मुझे यकीन नहीं था कि यह जानकारी कहां मिल रही थी। तो अब मैं भी पहले से कहीं अधिक संदेह में हूँ

Class-Path: jaxb-api.jar activation.jar jsr173_1.0_api.jar jaxb1-impl.jar 

: एक छोटे से अधिक अनुसंधान MANIFEST.MF में इस लाइन पाया। ऐसा लगता है कि जैक्सबी कार्यान्वयन एपीआई, सक्रियण, जेएसआर और जैक्सबी 1 कार्यान्वयन जार पर निर्भर करता है। लेकिन वे जैक्सब पोम में सूचीबद्ध नहीं हैं। ऑनलाइन एक छोटी खुदाई ने मुझे this link पाया जो जावा 6 एसई पर्यावरण में जेएक्सबी 2.2 का उपयोग करने के तरीके पर चर्चा करता है। दुर्भाग्यवश, यह या तो काम नहीं कर रहा है; मुझे अभी भी उपरोक्त चेतावनी संदेश मिलते हैं।

मैं चल रहा है जो JAXB कार्यान्वयन सूचीबद्ध करने के लिए निम्न स्निपेट का उपयोग कर रहा हूं; शायद यह गलत है?

/** 
* Print the JAXB Implementation information 
*/ 
public static void outputJaxpImplementationInfo() { 
    logger.debug(getImplementationInfo("DocumentBuilderFactory", DocumentBuilderFactory.newInstance().getClass())); 
    logger.debug(getImplementationInfo("XPathFactory", XPathFactory.newInstance().getClass())); 
    logger.debug(getImplementationInfo("TransformerFactory", TransformerFactory.newInstance().getClass())); 
    logger.debug(getImplementationInfo("SAXParserFactory", SAXParserFactory.newInstance().getClass())); 
} 

/** 
* Get the JAXB implementation information for a particular class 
* @param componentName 
* @param componentClass 
* @return 
*/ 
private static String getImplementationInfo(String componentName, Class componentClass) { 
    CodeSource source = componentClass.getProtectionDomain().getCodeSource(); 
    return MessageFormat.format(
      "{0} implementation: {1} loaded from: {2}", 
      componentName, 
      componentClass.getName(), 
      source == null ? "Java Runtime" : source.getLocation()); 
} 

यह स्निपेट निम्नलिखित लॉग पैदा करता है:

10:28:27,402 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,402 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - DocumentBuilderFactory implementation: __redirected.__DocumentBuilderFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar 
10:28:27,403 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,403 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - XPathFactory implementation: __redirected.__XPathFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar 
10:28:27,404 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,404 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - TransformerFactory implementation: __redirected.__TransformerFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar 
10:28:27,406 INFO [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,406 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil - SAXParserFactory implementation: __redirected.__SAXParserFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar 
+1

यह शायद कुछ डिग्री के लिए निर्भर JAXB कार्यान्वयन है। फॉ रिस्टेंस, जेएक्सबी आरआई को जेआरई 'एंडोर्सड' तंत्र के उपयोग की आवश्यकता होती है अगर मेमोरी की सेवा होती है। क्या आप कृपया अपने पर्यावरण के विवरण निर्दिष्ट कर सकते हैं: ऐप सर्वर, जेडीके संस्करण, जेएक्सबी इम्प्ले फॉर्म/से शुरू करने के लिए। –

+0

@PatriceM - क्षमा करें; उसमें शामिल होना भूल गए। इसे मूल प्रश्न को संपादित करने के लिए बस संपादित किया गया। –

+0

मैंने मूल पोस्ट को संपादित करने के लिए कुछ अतिरिक्त जानकारी जोड़ने के लिए संपादित किया है, यह इंगित करने के लिए कि मुझे जेएक्सबी कार्यान्वयन का उपयोग कैसे किया जा रहा है, साथ ही एक लिंक जो इंगित करता है कि जेआरई के डिफ़ॉल्ट जेएक्सबी कार्यान्वयन को ओवरराइड करना प्रतीत नहीं होता है काम कर रहे। –

उत्तर

12

नोट: मैं EclipseLink JAXB (MOXy) नेतृत्व और JAXB 2 (JSR-222) विशेषज्ञ समूह का सदस्य हूँ।

डिफ़ॉल्ट के अलावा एक जेएक्सबी (जेएसआर -222) कार्यान्वयन निर्दिष्ट करने के लिए आपको jaxb.properties नामक फ़ाइल को अपने डोमेन कक्षाओं के समान पैकेज में शामिल करने की आवश्यकता है। निम्नलिखित JAXB की MOXY कार्यान्वयन निर्दिष्ट करने के लिए प्रयोग किया जाता है jaxb.properties फ़ाइल का एक उदाहरण है: अधिक जानकारी के लिए

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory 

+4

टिप के लिए धन्यवाद; मुझे लगता है कि मैं याद रखने की कोशिश कर रहा था। लेकिन एक जेआरई और आपके युद्ध में एक ही कक्षा को देखते हुए, आप युद्ध में वर्ग या एक ऐप सर्वर प्रदान करने वाले वर्ग में कक्षा का उपयोग करने के लिए कैसे निर्दिष्ट करते हैं? –

+0

क्या यह काम करेगा? संकलन संकलन का अर्थ है कि आपको ऐप को संकलित करने और चलाने के लिए जार की आवश्यकता है। एक वेब अनुप्रयोग के लिए, उदाहरण के तौर पर, जेएआर को वेब-आईएनएफ/lib निर्देशिका में रखा जाएगा। – aurelius

2

यह JAXB कार्यान्वयन लोड करने के लिए संभव है Java Endorsed Standards Override Mechanism का उपयोग कर एक विशिष्ट पुस्तकालय से।यह गाइड Using JAXB 2.1/2.2 with JavaSE 6 में भी सुझाव दिया गया है।

वैकल्पिक रूप से, आपके एप्लिकेशन सर्वर में आप अपने आवेदन के लिए क्लास-लोडर पॉलिसी को अंतिम बार संशोधित कर सकते हैं ताकि कक्षाएं पहली बार जेआरई में खोजे जाने से पहले आपके आवेदन के साथ बंडल किए गए पुस्तकालयों में दिखाई दे सकें।

संबंधित मुद्दे