How to specify JAXBContext implementation in weblogic 12.1.3

梦想与她 提交于 2019-12-05 00:26:50

问题


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


回答1:


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



回答2:


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>



来源:https://stackoverflow.com/questions/31479282/how-to-specify-jaxbcontext-implementation-in-weblogic-12-1-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!