Jaxb3x bindings issue- Unsupported binding namespace "http://jaxb2-commons.dev.java.net/basic/inheritance"

178 Views Asked by At

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 .

1

There are 1 best solutions below

0
Nicholas Delello On

I just ran into the same issue. Try using http://jvnet.org/basicjaxb/xjc/inheritance instead.

It seems most projects I found on GitHub that use the xmlns:inheritance attribute use the same link as you, and they work for some reason. If you go to that link in a web browser, you'll see that it leads to a page telling you that the jaxb project is now owned by the eclipse foundation, not by Oracle or OpenJDK. Unfortunately, the eclipse foundation doesn't seem to have a link to an equivalent schema. The jvnet link worked for me, even though it doesn't resolve to anything in a web browser for me. If anyone finds an equivalent link from the eclipse foundation, that would be preferred, but until then, this is what seems to work.

Related Questions in JAKARTA-MIGRATION