Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
Last active May 5, 2021 10:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbietunnie/69310de4366039411ad11e367542155e to your computer and use it in GitHub Desktop.
Save barbietunnie/69310de4366039411ad11e367542155e to your computer and use it in GitHub Desktop.
JAX-WS import error for "A class/interface with the same name 'x.y.z.class' is already in use. Use a class customization to resolve this conflict."

A class/interface with the same name "x.y.z.class" is already in use. Use a class customization to resolve this conflict.

The issue is usually due to case-sensitivity error, where the same name for element and attribute issue (thru inheritance sometimes).

For case-sensitivity issues you can usexjc argument -XautoNameResolution, maven version is <args><arg>-B-XautoNameResolution</arg></args>.

When using external tools for code generation, specify the argument:

xjc argument -XautoNameResolution

For maven based projects, pass the -XautoNameResolution to the JAXB compiler .e.g

...
<plugins>
        <plugin>
            <groupId>org.jvnet.jax-ws-commons</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <xjcArgs>
                            <xjcArg>-XautoNameResolution</xjcArg>
                        </xjcArgs>
                        <wsdlFiles>
                            <wsdlFile>TheWSDL.wsdl</wsdlFile>
                        </wsdlFiles>
                        <packageName></packageName>
                        <vmArgs>
                            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                        </vmArgs>
                        <wsdlLocation>file:/C:/Users/username/Desktop/TheWSDL.wsdl</wsdlLocation>
                        <staleFile>${project.build.directory}/jaxws/stale/TheWSDL.stale</staleFile>
                    </configuration>
                    <id>wsimport-generate-TheWSDL</id>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>javax.xml</groupId>
                    <artifactId>webservices-api</artifactId>
                    <version>2.0</version>
                </dependency>
            </dependencies>
            <configuration>
                <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                <xnocompile>true</xnocompile>
                <verbose>true</verbose>
                <extension>true</extension>
                <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
            </configuration>
        </plugin>
    </plugins>
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment