在JBoss AS 7中找不到JAXB com.sun.xml.internal.bind.v2.ContextFactory类 [英] JAXB com.sun.xml.internal.bind.v2.ContextFactory Class Not Found in JBoss AS 7
本文介绍了在JBoss AS 7中找不到JAXB com.sun.xml.internal.bind.v2.ContextFactory类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在JBoss中使用JAXB时,我在执行代码时遇到异常:
While using JAXB in JBoss, I am getting below exception while executing the code:
JAXBContext jaxbContext = JAXBContext.newInstance( jaxbElement.getClass().getPackage().getName() );
我得到的例外情况是:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory from [Module "deployment.project.ear.subproject-jboss.jar:main" from Service Module Loader]]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:156) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar:1.0.4.Final-redhat-3]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:108) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar:1.0.4.Final-redhat-3]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:258) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar:1.0.4.Final-redhat-3]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar:1.0.4.Final-redhat-3]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar:1.0.4.Final-redhat-3]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:279) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar:1.0.4.Final-redhat-3]
看起来JBoss JAXB模块正在加载而不是JDK,这就是异常的原因,但我不是确定如何解决这个错误?
It looks like JBoss JAXB module is loading instead of JDK and this is the reason of exception, however I am not sure how to solve this error?
推荐答案
最后我通过将默认上下文工厂更改为eclipse链接上下文工厂来解决它,但不确定为什么它不适用于默认值。
Finally i solved it by changing default context factory to eclipse link context factory, but not sure why it does not worked with default one.
JAXBContext jaxbContext = JAXBContextFactory.createContext( clss.getPackage().getName() , clss.getClass().getClassLoader());
并导入 org.eclipse.persistence.jaxb.JAXBContextFactory
class。
这篇关于在JBoss AS 7中找不到JAXB com.sun.xml.internal.bind.v2.ContextFactory类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文