JAXB by default will attempt to create a Java class for each type
defined in the XSD, with the same name but with the first letter
upper-cased. In the case of 'dataset', it will try and make 'Dataset',
which then clashes with the existing 'Dataset' declared elsewhere in the
XSD.

The only way to stop it doing this and to generate class names that
match the XSD names exactly (thus avoiding the case clash) is to write a
plugin to JAXB to override the name conversion. An example of such a
plugin is on this page:

http://forums.java.net/jive/thread.jspa?threadID=13227

The plugin on that page converts all input to capital initial followed
by lower remainder, but you could probably work out how to change it to
just return names verbatim without modifying them at all.

Don't ask me how to use JAXB plugins though - I haven't quite worked
that out yet. :)

cheers,
Richard

Allyson Lister wrote:
> Hi all,
> 
> Thanks for the earlier help in getting my 0.7 checkout up to date and
> using the wsdl features that have been added.
> 
> I'm now using the wsdl2java feature (within maven) and CXF (version 2.1)
> to build some basic java classes that are based around the wsdl. I have
> one question that result from using these tools. (These tools basically
> take as input a wsdl file and generate java stubs that you can work with
> - all in a nice maven wrapper.)
> 
> 1. When I attempt to generate sources from the wsdl, I get the following
> complaint from maven about the wsdl's corresponding xsd:
> "Thrown by JAXB : A class/interface with the same name
> "uk.ac.ncl.mygrid._9002.martservicesoap.Dataset" is already in use. Use
> a class customization to resolve this conflict."
> 
> Having a look at where "Dataset" lives, you can see the following in the
> martxsd:
> 
>     <xs:complexType name="dataset">
>         <xs:sequence>
>             <xs:element name="name" type="xs:string"/>
>             <xs:element name="displayName" type="xs:string"/>
>             <xs:element name="type" type="xs:string"/>
>             <xs:element name="visible" type="xs:int"/>
>             <xs:element name="interface" type="xs:string"/>
>         </xs:sequence>
>     </xs:complexType>
> 
> [...]
> 
>     <xs:complexType name="Dataset">
>         <xs:sequence>
>             <xs:element minOccurs="1" maxOccurs="1" name="name"
> type="xs:string"/>
>             <xs:element minOccurs="0" maxOccurs="unbounded"
> name="Filter" type="tns:Filter"/>
>             <xs:element minOccurs="1" maxOccurs="unbounded"
> name="Attribute" type="tns:Attribute"/>
>         </xs:sequence>
>     </xs:complexType>
> 
> It seems the identical (except for casing) names causes problems for
> JAXB, which is being used by the wsdl2java command to generate the java
> code: if we kept both names, we'd end up with two Java classes with the
> same name. The same is true for the attribute/Attribute and
> filter/Filter names in the xsd. Changing the names of one of these (just
> to check that the compilation works afterward) solves the problem). For
> example, changing one of the dataset names to X_dataset solves the problem.
> 
> Is there anything that can be done about this in a larger biomart
> context, or should I find some sort of workaround just for me?
> 
> Thanks again!
> 
> -- 
> Thanks,
> Allyson :)
> 
> Allyson Lister
> Research Associate
> Centre for Integrated Systems Biology for Ageing and Nutrition
> Newcastle University
> http://www.cisban.ac.uk
> School of Computing Science
> Newcastle University
> Newcastle upon Tyne, NE1 7RU

-- 
Richard Holland, BSc MBCS
Finance Director, Eagle Genomics Ltd
M: +44 7500 438846 | E: [email protected]
http://www.eaglegenomics.com/

Reply via email to