chuck
chuck

Reputation: 23

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

My apache cxf client web service got exception just like below. However, 'XML type name "address"' is the soap:address location of my WSDL. What is the problem?

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

Upvotes: 2

Views: 11396

Answers (2)

tasos panagiotopoulos
tasos panagiotopoulos

Reputation: 21

I have encountered exactly the same issue. This is not a solution but a workaround.

First of all, the wsdl based on which I had built my client was an autogenerated wsdl. This type of wsdls usually contain more than one shema, like in my case (4 schemas). I don't say that this is wrong but in my case what I did was to remove the last 3 schemas and move all the elements inside the first one along with what that entails (changes in namespaces etc.). After doing this I built my client again and the error was solved.

Upvotes: 0

lexicore
lexicore

Reputation: 43661

This is interesting. This is not a full answer, but this might help.

The com.sun.xml.ws.developer.MemberSubmissionEndpointReference.Address class is not annotated, there's also no package-info.java. So the type should be named address, without namespace.

The class javax.xml.ws.wsaddressing.W3CEndpointReference.Address is also not annotated, but there is a 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;

So it should be named {http://www.w3.org/2005/08/addressing:address. So theoretically there should be no conflict.

I'd suggest the following:

  • Check your classes and packages.
    • Do you have a package-info.java in javax.xml.ws.wsaddressing?
    • Do you have one in com.sun.xml.ws.developer?
  • Try updating versions of your libraries. Maybe this was a temporary glitch between versions.

UPDATE

I have found exactly the same problem reported on java.net. One of the solutions posted there is, basically, "update your versions". Also seems to be relevant to NetBeans somehow.

Upvotes: 1

Related Questions