0

Upgrading to jaxb jakarta i'm getting issue with inheritence namespace.

Purpose: Converting xsd to java files

My xjb file:

<jaxb:bindings version="3.0"

xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"

xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"

xmlns:xs="http://www.w3.org/2001/XMLSchema" 

xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"

jaxb:extensionBindingPrefixes="inheritance">

<jaxb:globalBindings>

<xjc:simple />

<jaxb:javaType name="java.lang.String" xmlType="xs:date" />

<jaxb:javaType name="java.lang.String" xmlType="xs:time" />

<jaxb:serializable />

</jaxb:globalBindings>

<jaxb:bindings schemaLocation="&xsdPath;/sample.xsd">

<jaxb:bindings node="//xs:element[@name='sampleRequest']/xs:complexType">

<inheritance:implements>&baseRequest;</inheritance:implements>

</jaxb:bindings>

<jaxb:bindings node="//xs:element[@name='sampleResponse']/xs:complexType">

<inheritance:implements>&baseResponse;</inheritance:implements>

</jaxb:bindings>

</jaxb:bindings>

</jaxb:bindings>

My pom.xml configuration : Below is the plugin configuration for jaxb

<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>jaxb2-maven-plugin</artifactId>

<version>3.1.0</version>

<executions>

<execution>

<id>xjc</id>

<goals><goal>xjc</goal>
</goals>

</execution>

</executions>

<configuration>

<args>

<arg>-Xinject-code</arg>

<arg>-Xinheritance</arg>

<arg>-XautoNameResolution</arg>

</args>

<dependencies>

<dependency>

<groupId>jakarta.xml.bind</groupId>

<artifactId>jakarta.xml.bind-api</artifactId>

<version>4.0.0</version>

</dependency>

<dependency>

<groupId>com.sun.xml.bind</groupId>

<artifactId>jaxb-core</artifactId>

<version>4.0.3</version>

</dependency>

<dependency>

<groupId>com.sun.xml.bind</groupId>

<artifactId>jaxb-impl</artifactId>

<version>4.0.3</version>

</dependency>

</dependencies>

<xjbSources>

<xjbSource>src/main/resources/schema/xjb/MyJaxbBindings.xjb</xjbSource>

</xjbSources>

<sources>

<source>src/main/resources/schema/xsd</source>

</sources>

<packageName>com.demo.generated.model</packageName>

<outputDirectory>${project.build.directory}/generated-sources/jaxb</outputDirectory>

<clearOutputDir>false</clearOutputDir>

<noGeneratedHeaderComments>true</noGeneratedHeaderComments>

<extension>true</extension>

<generateEpisode>false</generateEpisode>

</configuration>

</plugin>

when i did maven build it gives error as "Unsupported binding namespace http://jaxb2-commons.dev.java.net/basic/inheritance. Perhaps you meant http://jaxb.dev.java.net/plugin/code-injector?"

when i replace it with http://jaxb.dev.java.net/plugin/code-injector it gives me other error as Using http://jaxb.dev.java.net/plugin/code-injector customizations requires the "-Xinject-code" switch to enable this plug-in.

Not able to find the solution to fix this issue.Please help me to resolve the namespace issue for inheritance, what need to configured for jakarta jaxb for version 3 .

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
SreeNath
  • 91
  • 1
  • 4

0 Answers0