facebook

[Closed] Errors Generating Web Service Client – JAXB

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #273427 Reply

    fobinator
    Member

    Version: 6.0.0 M1
    Build id: 20070629-6.0.0-M1
    JDK: jdk1.6.0_02

    Error generating services
    Error generating JAXB model.

    I’m having some issues with client generation, checking the error log I see the following message snippets

    !MESSAGE A class/interface with the same name “com.ws.QueryResponse” is already in use. Use a class customization to resolve this conflict.

    !ENTRY com.genuitec.eclipse.ws.xfire 4 0 2007-08-01 22:21:03.885
    !MESSAGE Two declarations cause a collision in the ObjectFactory class.
    !STACK 0
    com.sun.istack.SAXParseException2: Two declarations cause a collision in the ObjectFactory class.

    !ENTRY com.genuitec.eclipse.ws.xfire 4 0 2007-08-01 22:21:03.963
    !MESSAGE Error generating services
    !STACK 0
    org.codehaus.xfire.gen.GenerationException: Error generating JAXB model.
    at org.codehaus.xfire.gen.jaxb.JAXBSchemaSupport.initialize(JAXBSchemaSupport.java:108)
    at org.codehaus.xfire.gen.Wsdl11Generator.generate(Wsdl11Generator.java:154)
    at com.genuitec.eclipse.ws.xfire.generator.WSGenJob.run(WSGenJob.java:209)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

    My WSDL passed validation, can anyone tell me what’s going on?

    #273445 Reply

    Loyal Water
    Member

    Can you try the following approaches to fix the issue:-

    Two declarations cause a collision in the ObjectFactory class
    When schemas contain similar looking element/type names, they can result in “Two declarations cause a collision in the ObjectFactory class” errors. To be more precise, for each of all types and many elements (exactly what elements get a factory and what doesn’t is bit tricky to explain), XJC produces one method on the ObjectFactory class in the same package. The ObjectFactory class is created for each package that XJC generates some files into. The name of the method is derived from XML element/type names, and the error is reported if two elements/types tries to generate the same method name.

    There are two approaches to fix this problem. If the collision is coming from two different schemas with different target namespaces, then you can easily avoid the collision by compiling them into different Java packages. To do this, use <schemabindings> customization on two schemas and specify the package name.

    Another way to fix this problem is to use <factoryMethod> customization on two conflicting elements/types to specify different factory method names. This can be used in all cases, but if you have a large number of conflicts, you’ll have to specify this customization one by one.

    Notice that <class> customization doesn’t affect the ObjectFactory method name by itself.

    #273452 Reply

    fobinator
    Member

    Thanks for the response, I think I’ll have to use the <factoryMethod> customization, but I’m not really sure what this means? What would I need to change?

    #274070 Reply

    spulakanam
    Member

    I switched from JDK 1.5 to JDK 1.6 and using Jaxb 2.1.4. I am trying to compile the schema using Ant in my Eclipse. The schema is pretty simple and I get the following exception.
    I guess from the above posts I understand some how I need to do the <factoryMethod> customization. Some one care to explain what does this mean?

    [xjc] build id of XJC is JAXB 2.0 in JDK 1.6
    [xjc] Checking timestamp of /Users/spulakanam/Documents/workspace/DigitalSidebarDCS/xmlschema/userevents.xsd
    [xjc] the last modified time of the inputs is 1187387812000
    [xjc] the last modified time of the outputs is -9223372036854775808
    [xjc] Compiling file:/Users/spulakanam/Documents/workspace/DigitalSidebarDCS/xmlschema/userevents.xsd
    [xjc] [ERROR] A class/interface with the same name “generated.Data” is already in use. Use a class customization to resolve this conflict.
    [xjc] line 3 of file:/Users/spulakanam/Documents/workspace/DigitalSidebarDCS/xmlschema/userevents.xsd
    [xjc] [ERROR] (Relevant to above error) another “Data” is generated from here.
    [xjc] line 8 of file:/Users/spulakanam/Documents/workspace/DigitalSidebarDCS/xmlschema/userevents.xsd
    [xjc] [ERROR] Two declarations cause a collision in the ObjectFactory class.
    [xjc] line 8 of file:/Users/spulakanam/Documents/workspace/DigitalSidebarDCS/xmlschema/userevents.xsd
    [xjc] [ERROR] (Related to above error) This is the other declaration.
    [xjc] line 3 of file:/Users/spulakanam/Documents/workspace/DigitalSidebarDCS/xmlschema/userevents.xsd
    [xjc] failure in the XJC task. Use the Ant -verbose switch for more details

    #274071 Reply

    spulakanam
    Member

    It was my mistake building the xsd using RelaxNG. I got it working.

    #274117 Reply

    Loyal Water
    Member

    Glad its working now. Thanks for letting us know.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: [Closed] Errors Generating Web Service Client – JAXB

You must be logged in to post in the forum log in