Jboss EAP 6.4.4类加载jaxb jar

时间:2017-09-29 10:32:34

标签: web-services jboss jaxb cxf classloader

我尝试在jboss 6.4.4上部署Web应用程序。 ear文件包含Jaxb jar。 调用Web服务时,xml绑定存在问题:

ClassCastException: attempting to cast vfs:/content/App.ear/jaxb-api-2.1.jar/javax/xml/bind/JAXBContext.class to jar:__file:/home/myworkingfolder/jboss-eap-6.4.4/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar!/javax/xml/bind/JAXBContext.class. 
Please make sure that you are specifying the proper ClassLoader.

如何排除jboss jaxb lib?

感谢。

1 个答案:

答案 0 :(得分:0)

jar jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-3.jar包含在模块" javax.xml.bind.api"。

1-我在jboss-deployment-structure.xml文件中排除了这个模块,开始尝试。

<exclusions>

<module name="javax.xml.bind.api"/>

</exclusions>

即使有明确排除,也不排除该模块。

此模块由javaee模块隐式加载。

2-所以我试图排除javaee模块并将其module.xml内容放在jboss-deployment-structure.xml中,而不使用javax.xml.bind.api模块

<module name="javaee.api"/>

</exclusions>

<dependencies>

<module name="javax.activation.api" export="true"/>

<module name="javax.annotation.api" export="true"/>

<module name="javax.ejb.api" export="true"/>

<module name="javax.el.api" export="true"/>

<module name="javax.enterprise.api" export="true"/>

<module name="javax.enterprise.deploy.api" export="true"/>

<module name="javax.inject.api" export="true"/>

<module name="javax.interceptor.api" export="true"/>

<module name="javax.jms.api" export="true"/>

<module name="javax.jws.api" export="true"/>

<module name="javax.mail.api" export="true"/>

<module name="javax.management.j2ee.api" export="true"/>

<module name="javax.persistence.api" export="true"/>

<module name="javax.resource.api" export="true"/>

<module name="javax.rmi.api" export="true"/>

<module name="javax.security.auth.message.api" export="true"/>

<module name="javax.security.jacc.api" export="true"/>

<module name="javax.servlet.api" export="true"/>

<module name="javax.servlet.jsp.api" export="true"/>

<module name="javax.transaction.api" export="true"/>

<module name="javax.validation.api" export="true"/>

<module name="javax.ws.rs.api" export="true"  services="export"/>

<!-- <module name="javax.xml.bind.api" export="true"/> -->

<module name="javax.xml.registry.api" export="true"/>

<module name="javax.xml.soap.api" export="true"/>

<module name="javax.xml.ws.api" export="true"/>



<!-- This one always goes last. -->

<module name="javax.api" export="true"/>

<dependencies>

此方法不包括javax.xml.bind.api。

但我遇到了这个错误:

Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/frontend/ClientProxy

我通过在依赖项中添加cxf解决了这个错误:

<module name="org.jboss.ws.cxf.jbossws-cxf-client" services="import" />

<module name="org.apache.cxf.impl">

    <imports>

        <include path="META-INF"/>

        <include path="META-INF/cxf"/>

    </imports>

</module>

jboss-deployment-structure.xml变得非常冗长...... 任何其他解决方案?