本文介绍了如何在weblogic 12.1.3中指定JAXBContext实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JAXB在java中创建了一个MDB来解析xml内容。
这个MDB在10.3.4 weblogic服务器上工作了很长时间(大约3年)。

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.

现在我要将它迁移到weblogic 12.1.3服务器,由于我还不知道的原因,weblogic选择的实现与我想要的不一样。但我无法弄清楚如何设置它。

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由JAXB从XSD生成。

MyClass.java is generated by JAXB from an XSD.

在我的eclipse上,输出是 com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl

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

在我的weblogic方面,输出是 org.eclipse.persistence.jaxb.JAXBContext

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

推荐答案

当我通过EAR使用我的代码时,我不得不放这些行:

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>  

并在我的EAR services / javax.xml的META-INF目录中创建文件.bind.JAXBContex 只包含,它可以工作

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

这篇关于如何在weblogic 12.1.3中指定JAXBContext实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 09:21