Glassfish Metro: resolving JAXB naming conflicts and customizing packages names

Susan Genoray
Susan Genoray Contributor

During the generation of proxy classes for TRKD API services using Glassfish Metro (wsimport tool) we are getting errors like these:

[wsimport] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.

[wsimport] line 56 of jar:file:/D:/runtime/metro-2.1.1/lib/webservices-tools.jar!/com/sun/xml/xsom/impl/parser/datatypes.xsd

[wsimport] [ERROR] The following location is relevant to the above error

[wsimport] line 436 of http://api.rkd.reuters.com/schemas/Fundamentals/LookUp_1.xsd

Could this be a problem with name collision within the files? If so, how can I resolve this conflict?

Tagged:

Best Answer

  • DevTrev
    DevTrev Advocate
    Answer ✓

    These errors are known for some services (e.g. Fundamentals, SignificantDevelopments, etc) during the generation of proxy classes for TRKD API services using the Glassfish Metro (wsimport) tool.

    In this example, the reason of such error was in the name collision. LookUp_1.xsd file (part of TRKD Fundamentals service definition) contains the element Value identical to a JAX-WS internally declared element.

    In order to resolve the conflict you need to re-define name of the collision element using custom JAXB bindings like the following (e.g. using toValue instead of Value):

    <jaxb:bindings schemaLocation=http://api.rkd.reuters.com/schemas/Fundamentals/LookUp_1.xsd node="/xs:schema">

    <jaxb:bindings schemaLocation=http://api.rkd.reuters.com/schemas/Fundamentals/LookUp_1.xsd node=".//xs:attribute[@name='Value']">
    <jaxb:property name="toValue"/>

    </jaxb:bindings>

    </jaxb:bindings>

    Another feature of JAXB bindings that might come in handy is the customization of package names which can help make package name more readable. By default wsimport generates package names based on target namespace URI like the following:

    com.reuters.ns._2006._05._01.webservices.rkd.quotes_1

    In order to get something similar to:
    com.reuters.webservice.rkd.quotes
    You need to define the following binding:
    <jaxb:bindings schemaLocation="http://api.rkd.reuters.com/schemas/Quotes/Quotes_1.xsd" node="/xs:schema">

    <jaxb:schemaBindings>
    <jaxb:package name="com.reuters.webservice.rkd.quotes" />


    </jaxb:schemaBindings>

    </jaxb:bindings>