简体   繁体   English

CXF 和 JBoss 6.4:两个类具有相同的 XML 类型名称

[英]CXF and JBoss 6.4: Two Classes Have the same XML Type Name

I have an issue when deploying my CXF project to JBoss EAP 6.4 that does NOT seem to be covered by other people asking about this issue.在将我的 CXF 项目部署到 JBoss EAP 6.4 时,我遇到了一个问题,其他人询问这个问题似乎没有涵盖。

I am receiving the following stack trace when I attempt to deploy:当我尝试部署时收到以下堆栈跟踪:

14:02:08,701 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 119) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AdminServices': Invocation of init method failed; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
    (snip)
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
    (snip)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:329) [cxf-rt-databinding-jaxb-3.1.13.jar:3.1.13]
    at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86) [cxf-core-3.1.13.jar:3.1.13]
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:470) [cxf-rt-wsdl-3.1.13.jar:3.1.13]
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:696) [cxf-rt-frontend-jaxws-3.1.13.jar:3.1.13]
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:530) [cxf-rt-wsdl-3.1.13.jar:3.1.13]
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263) [cxf-rt-wsdl-3.1.13.jar:3.1.13]
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199) [cxf-rt-frontend-jaxws-3.1.13.jar:3.1.13]
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103) [cxf-rt-frontend-simple-3.1.13.jar:3.1.13]
    at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168) [cxf-rt-frontend-simple-3.1.13.jar:3.1.13]
    at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211) [cxf-rt-frontend-jaxws-3.1.13.jar:3.1.13]
    at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460) [cxf-rt-frontend-jaxws-3.1.13.jar:3.1.13]
    at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338) [cxf-rt-frontend-jaxws-3.1.13.jar:3.1.13]
    ... 32 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 208 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://app.application.com/adminServices}addCatalog". Use @XmlType.name and @XmlType.namespace to assign different names to them.

(sample) (样本)

Two classes have the same XML type name "{http://app.application.com/adminServices}updateQuantityAllocationResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
    at com.jason.app.control.jaxws_asm.UpdateQuantityAllocationResponse
this problem is related to the following location:
    at com.jason.app.adminservices.UpdateQuantityAllocationResponse
    at public javax.xml.bind.JAXBElement com.jason.app.adminservices.ObjectFactory.createUpdateQuantityAllocationResponse(com.jason.app.adminservices.UpdateQuantityAllocationResponse)
    at com.jason.app.adminservices.ObjectFactory

I do NOT recognize the com.jason.app.control.jaxws_asm package, and it does not exist in the EAR file I am deploying.我不认识 com.jason.app.control.jaxws_asm package,它不存在于我正在部署的 EAR 文件中。 This implies to me that JBoss is doing something, but I have no idea what.这对我来说意味着 JBoss 正在做某事,但我不知道是什么。

My jboss-deployment-structure.xml is simple, only excluding the built-in webservices subsystem since I am using a more modern version of CXF.我的 jboss-deployment-structure.xml 很简单,只排除了内置的 web 服务子系统,因为我使用的是更现代的 CXF 版本。

<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">  <ear-subdeployments-isolated>false</ear-subdeployments-isolated>    <deployment>        <exclude-subsystems>            <subsystem name="webservices" />        </exclude-subsystems>   </deployment> </jboss-deployment-structure>

I am totally stumped on this issue.我完全被这个问题难住了。 If anyone can help, I would appreciate.如果有人可以提供帮助,我将不胜感激。 I will post more information if requested.如果需要,我会发布更多信息。

I assume you have this class defined: at com.jason.app.adminservices.UpdateQuantityAllocationResponse 我假设您已定义此类: com.jason.app.adminservices.UpdateQuantityAllocationResponse

In your WS, you probably have a method that contains something like this: @WebMethod //exposed as operation in your WS @ResponseWrapper(localName = " UpdateQuantityAllocation ") //this is the wrapper element in the response 在您的WS中,您可能有一个包含如下内容的方法:@WebMethod //作为WS中的操作公开@ResponseWrapper(localName =“ UpdateQuantityAllocation ”)//这是响应中的包装器元素

CXF/JAXB generates this class: at com.jason.app.control.jaxws_asm.UpdateQuantityAllocation Response CXF / JAXB生成此类: com.jason.app.control.jaxws_asm.UpdateQuantityAllocation 响应

Thus you end up with 2 classes having same name. 因此,您最终得到了两个具有相同名称的类。

Happened the same to me, in my case, i copy-pasted the generated client classes from another project (for the same WS), but the package was different.对我来说也是如此,在我的例子中,我从另一个项目(对于同一个 WS)复制粘贴了生成的客户端类,但是 package 是不同的。 IDE automatically fixed the package from JAVA headers, but didn't changed the string in @ResponseWrapper attributes. IDE 自动修复了 JAVA 标头中的 package,但没有更改 @ResponseWrapper 属性中的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM