0

I'm trying to revive a legacy project for my client. The project is pretty old and it uses the jaxb2-maven-plugin to generate some java classes from an xsd schema file.

   <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>jaxb2-maven-plugin</artifactId>
      <version>2.4</version>
      <executions>
         <execution>
            <goals>
               <goal>xjc</goal>
            </goals>
         </execution>
      </executions>
      <configuration>
         <sources>
            <source>src/main/resources/custom-api.xsd</source>
         </sources>
         <packageName>com.client</packageName>
         <catalog>src/main/resources/catalog.cat</catalog>
      </configuration>
   </plugin>

The problem is the company doesn't allow any internet access - hence when I generate the code I get errors such as java.net.UnknownHostException saying that it cannot find www.springframework.org.

So I understand that the solution for this problem is to provide the xsd files locally - which I did, extracting them in a folder named import and I created also a catalog.cat file to rewrite the access to those xsd files to the import folder.

The catalog.cat file looks like this:

REWRITE_SYSTEM "http://www.springframework.org/schema/beans/spring-beans-3.1.xsd" "import/spring-beans-3.1.xsd"
REWRITE_SYSTEM "http://www.mulesoft.org/schema/mule/core/3.4/mule.xsd" "import/mule.xsd"
REWRITE_SYSTEM "http://www.mulesoft.org/schema/mule/schemadoc/3.4/mule-schemadoc.xsd" "import/mule-schemadoc.xsd"
REWRITE_SYSTEM "http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd" "import/mule-jms.xsd"
REWRITE_SYSTEM "http://www.springframework.org/schema/context/spring-context-3.1.xsd" "import/spring-context-3.1.xsd"
REWRITE_SYSTEM "http://www.springframework.org/schema/tool/spring-tool-3.1.xsd" "import/spring-tool-3.1.xsd"

Unfortunately I get some conflicts in spring-beans.xsd:

com.sun.istack.SAXParseException2publicId: http://www.springframework.org/schema/beans; systemId: http://www.springframework.org/schema/beans/spring-beans-3.1.xsd; lineNumber: 566; columnNumber: 30; Property "Ref" is already defined. Use &lt;jaxb:property> to resolve this conflict.
                at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:56)

I suspect that this happens because the xsd is loaded multiple times - probably being referenced by other xsd files. The usual way to get rid of such conflicts is to use a binding file, but I don't think this is the right thing to do considering that this is a third party xsd file.

An example of a sample project has been provided here: https://github.com/scutaru/sample-xjc

Anybody knows how I can get rid of these conflicts ?

Ionut
  • 103
  • 9
  • I just tagged this question with maven-jaxb2-plugin because I changed the plugin from jaxb2-maven-plugin to maven-jaxb2-plugin and I get the same result. I even have a small sample project that can be used to reproduce the error. – Ionut Jul 22 '22 at 12:26
  • Does this answer your question? [JAXB - Property "Value" is already defined. Use to resolve this conflict](https://stackoverflow.com/questions/4394134/jaxb-property-value-is-already-defined-use-jaxbproperty-to-resolve-this) – Simon Martinelli Jul 22 '22 at 12:50

0 Answers0