2

I have a Vendor.xsd, where the namespace definition is referencing a vendor specific namespace http://vendor.com/xjc-plugins. A snippet is given below:

...
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:common="http://annox.dev.java.net" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:vendor="http://vendor.com/xjc-plugins"
elementFormDefault="qualified" 
jaxb:extensionBindingPrefixes="vendor common" 
jaxb:version="2.0"> 
...
xs:complexType name="VendorType">
    <xs:annotation>
        <xs:appinfo>
            <vendor:package>vendor.package</vendor:package>
        </xs:appinfo>
    </xs:annotation>
...

When I try to generate jaxbs by using either xjc from command line or maven-jaxb22-plugin the following exception occurs:

Unsupported binding namespace "http://vendor.com/xjc-plugins". Perhaps you meant "http://annox.dev.java.net"?

The maven plugin I am using is given here:

      <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb22-plugin</artifactId>
    <version>0.13.1</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <schemaDirectory>src/main/resources</schemaDirectory>
          <schemaIncludes>
            <include>Vendor.xsd</include>
          </schemaIncludes>
          <generatePackage>com.vendor.model</generatePackage>
          <extension>true</extension>
          <args>
            <arg>-Xannotate</arg>
          </args>
          <plugins>
            <plugin>
              <groupId>org.jvnet.jaxb2_commons</groupId>
              <artifactId>jaxb2-basics-annotate</artifactId>
              <version>1.0.2</version>
            </plugin>
            <plugin>
              <groupId>org.jvnet.jaxb2_commons</groupId>
              <artifactId>jaxb2-basics</artifactId>
              <version>1.11.1</version>
            </plugin>
            <plugin>
              <groupId>org.jvnet.jaxb2_commons</groupId>
              <artifactId>jaxb2-basics-tools</artifactId>
              <version>1.11.1</version>
            </plugin>
          </plugins>
        </configuration>
      </execution>
    </executions>
  </plugin>

Any ideas welcome ?

theo
  • 915
  • 1
  • 9
  • 28

1 Answers1

2

You do not seem to include your XJC plugin in plugins section of the maven-jaxb2-plugin configuration. Binding namespace must be acknowledged by some plugin. You only include jaxb2-basics but not the plugin which would acknowledge http://vendor.com/xjc-plugins.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • So are you saying I would need to get hold of the vendor jxc plugin jar ?.. assuming that there is one – theo Nov 17 '16 at 14:50
  • A long as you have `jaxb:extensionBindingPrefixes="vendor"`, you'll need a plugin to acknowledge the `vendor` namespace. Either get the plugin OR write a plugin which would just acknowledge these customizations OR remove `jaxb:extensionBindingPrefixes="vendor"` for instance by patching the schema prior to processing. Finally, talk to the vendor, this XJC-specific stuff does not belong to public schemas. Vendor should move it out of their schema into a binding file. – lexicore Nov 17 '16 at 14:58