4

I am not able to get AutoNameResolution to work in maven-jaxb2-plugin. Below is my pom file

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.2</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <args>
             <arg>-XautoNameResolution</arg>
         </args>
        <schemaLanguage>WSDL</schemaLanguage>
        <generatePackage>com.commp.soap.service</generatePackage>
        <schemas>
            <schema>
                <url>https://urltowsdl</url>
            </schema>
        </schemas>
    </configuration>
</plugin>

I am not able to figure out where I am going wrong. All I get in the error is "A class/interface with the same name is already in use. Use a class customization to resolve this conflict." Since I am consuming a third-party wsdl, from which most functions I wont be consuming I just want a simple autoresolve rather than writing bindings for stuff I donot use.

I tried with apache cxf as well.

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>stock-quote-service</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.basedir}/src/main/generated_java</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${project.basedir}/src/main/resources/wsdl/consume.wsdl</wsdl>
                        <wsdlLocation>http://usrltoWsdl</wsdlLocation>
                        <serviceName>Consumer</serviceName>
                        <extraargs>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>com.projects.webservicex.service</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-ts</artifactId>
            <version>2.2.9</version>
        </dependency>
    </dependencies>
</plugin>

I ran this with both <extraarg>-autoNameResolution</extraarg> and

<defaultOptions>
    <autoNameResolution>true</autoNameResolution>
</defaultOptions>

Still the same issue "Two declarations cause a collision in the ObjectFactory class."

How can I just get autoNameResolve to work?

EDIT I see log like the following in the debug.

[DEBUG] Resolving publicId [http://url/webservices/es/common], systemId [null].
resolvePublic(http://url/webservices/es/common,null)
[DEBUG] Parent resolver has resolved publicId [http://url/webservices/es/common], systemId [null] to [null].
[DEBUG] Resolving publicId [http://url/webservices/es/constants], systemId [null].
resolvePublic(http://url/webservices/es/constants,null)

1 Answer 1

5

Try to remove:

<generatePackage>com.commp.soap.service</generatePackage>

and

<extraarg>-p</extraarg>
<extraarg>com.projects.webservicex.service</extraarg>
2
  • This actually worked!! By why? i am sure my package naming was different from the package names that where there in the generated files. But more importantly after removing the package names, I didn't even need autoNameResolution.
    – Manoj
    Commented Nov 1, 2017 at 14:28
  • 1
    You dont need autoNameResolution option, because there isn't two definition of the same class in the same namespace, this occours only when you try to change destination package name. However this isn't related to these maven plugin but directly to "jaxb and xjc".
    – Macondo
    Commented Nov 2, 2017 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.