Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify JAXBContext implementation in weblogic 12.1.3

Tags:

xml

jaxb

weblogic

I have created a MDB in java using JAXB to parse the xml content. This MDB is working from a long time now (about 3 years) on a 10.3.4 weblogic server.

Now I've to migrate it on a weblogic 12.1.3 server, and for a reason I'm not knowing yet, the implemention choose by weblogic isn't the same as I want. But I can't figure out how to set it.

Right now my code init code is this :

private JAXBContext getJAXBContext() throws JAXBException {
    if (v1JaxbContext == null) {
       v1JaxbContext = JAXBContext.newInstance(MyClass.class);
    }
    System.out.println("jaxbContext : "+v1JaxbContext.getClass().getName());
    return v1JaxbContext;
}

MyClass.java is generated by JAXB from an XSD.

On my eclipse the output is com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl

On my weblogic side the ouput is org.eclipse.persistence.jaxb.JAXBContext

like image 268
RVA Avatar asked Jul 17 '15 15:07

RVA


2 Answers

As i was using my code through an EAR I had to put these lines :

<wls:prefer-application-resources>
    <resource-name>META-INF/services/javax.xml.bind.JAXBContext</resource-name>
</wls:prefer-application-resources>  

And create the file in the META-INF directory of my EAR services/javax.xml.bind.JAXBContex which contains only, and it works

com.sun.xml.bind.v2.ContextFactory
like image 81
RVA Avatar answered Nov 14 '22 08:11

RVA


I faced the same issue and worked out similar solution which doesn't require creating a new file:

<prefer-application-resources> <resource-name>javax.xml.bind.*</resource-name> </prefer-application-resources>

like image 2
Artemis Avatar answered Nov 14 '22 08:11

Artemis