java - com.sun.xml.bind.v2.runtime.IllegalAnnotationsException : 2 counts of IllegalAnnotationExceptions

标签 java web-services jaxb cxf

我的 apache cxf 客户端 Web 服务出现异常,如下所示。但是,“XML 类型名称“地址””是我的 WSDL 的 soap:address 位置。问题是什么?

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "address". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address
        at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Address com.sun.xml.ws.developer.MemberSubmissionEndpointReference.addr
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
    this problem is related to the following location:
        at javax.xml.ws.wsaddressing.W3CEndpointReference$Address
        at private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address
        at javax.xml.ws.wsaddressing.W3CEndpointReference
Two classes have the same XML type name "elements". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
        at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties
        at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
    this problem is related to the following location:
        at javax.xml.ws.wsaddressing.W3CEndpointReference$Elements
        at private javax.xml.ws.wsaddressing.W3CEndpointReference$Elements javax.xml.ws.wsaddressing.W3CEndpointReference.referenceParameters
        at javax.xml.ws.wsaddressing.W3CEndpointReference

最佳答案

这很有趣。这不是完整的答案,但这可能会有所帮助。

com.sun.xml.ws.developer.MemberSubmissionEndpointReference.Address 类没有注释,也没有 package-info.java。所以类型应该命名为address,没有命名空间。

javax.xml.ws.wsaddressing.W3CEndpointReference.Address类也没有注释,但是有一个package-info.java:

@javax.xml.bind.annotation.XmlSchema(namespace=W3CEndpointReference.NS,
                                     location="http://www.w3.org/2006/03/addressing/ws-addr.xsd")
package javax.xml.ws.wsaddressing;

所以它应该被命名为{http://www.w3.org/2005/08/addressing:address。所以理论上应该不会有冲突。

我建议如下:

  • 检查你的类和包。
    • javax.xml.ws.wsaddressing 中是否有package-info.java
    • com.sun.xml.ws.developer 中有吗?
  • 尝试更新您的库版本。也许这是版本之间的临时故障。

更新

我发现了完全相同的问题reported on java.net .那里发布的解决方案之一基本上是“更新您的版本”。似乎也以某种方式与 NetBeans 相关。

关于java - com.sun.xml.bind.v2.runtime.IllegalAnnotationsException : 2 counts of IllegalAnnotationExceptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15680663/

相关文章:

c# - 是否混合使用 asp.net mvc 应用程序和 Web API

java - Jaxb 未解码 xml

c++ - gSOAP WSSE header 缺少 xmlns 命名空间声明

java - 如何使用jsp获取下拉值:useBean and jsp:setProperty?

java - 在 JUnit 中比较两个 Hibernate session 是否相同

Java for 循环评估

java - Spring Webservices 将元素添加到 Soap 请求

java - 通过 Jettison 将 Java 对象(不带 @XmlRootElement)编码为 JSON

java - JAXB 不将 xml 任何元素解码为 JAXBElement

java - GAE JDO - 建模这些关系的正确方法是什么?