I am trying to use Maven to generate JAXB files to be used by Spring framework, but Maven displays following errors:
I understand that it is unable to generate files with the names, but I am not sure how to resolve the issue. So far, I visited following links. 1, 2, 3
org.xml.sax.SAXParseException; systemId: http://www5v80.elsyarres.net/service.asmx?wsdl; lineNumber: 5; columnNumber: 39; A class/interface with the same name "hello.wsdl.SearchFlights" is already in use. Use a class customization to resolve this conflict.
....
org.xml.sax.SAXParseException; systemId: http://www5v80.elsyarres.net/service.asmx?wsdl; lineNumber: 12; columnNumber: 43; (Relevant to above error) another "SearchFlights" is generated from here.
....
org.xml.sax.SAXParseException; systemId: http://www5v80.elsyarres.net/service.asmx?wsdl; lineNumber: 371; columnNumber: 42; A class/interface with the same name "hello.wsdl.GetFlightDetails" is already in use. Use a class customization to resolve this conflict.
....
Maven plugin
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>hello.wsdl</generatePackage>
<schemas>
<schema>
<url>http://www5v80.elsyarres.net/service.asmx?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
I added following package-info.java
file to the hello.wsdl
package but it did not help.
@XmlSchema(
namespace = "ElsyArres.API",
elementFormDefault = XmlNsForm.QUALIFIED)
package hello.wsdl;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
Removing
<generatePackage></generatePackage>
tag solved my problem.The error message you are facing basically states that some names in the the
types
section of your wsdl are you used two times. In your case all<element>
tags have the same name as their corresponding types (defined as<complexType>
).Example:
This is quite uncommon.
There are basically two options to resolve these issues:
Use autoNameResolution
The plugin will resolve all naming conflicts through appending numbers to every colliding name. In the above mentioned case of SearchFlights this will result in SearchFlights and SearchFlights2 being generated.
A better way would be to use a binding file to resolve all name conflicts in advance. Binding files mostly contain
XPATH
expression and transformation rules. A binding file that appends to every declarations name is the following:There are other options for
jaxb:nameXmlTransform
like suffixes and prepending to other kind of xml elements (like types).Sadly i could not get to work this binding file with the
org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
( but i am sure there is a working configuration)It nevertheless works with the
org.codehaus.mojo:jaxws-maven-plugin
and the following configuration.If the autoNameResolution fix
doesn't work, try: