I am trying to get Maven to generate a JAXB binding using nested xml schemas: schema A imports schema B. Schema B imports schema C.
Everything builds just fine if objects in schema A reference objects in schema B that do not depend on a schema C object. If the object in schema B references an object in schema C it breaks. That is, going one level deep works. Going two deep does not.
As soon as I add an object in schema A that references an object in schema B, which in turn references an object in schema C, I get a org.xml.sax.SAXParseException: rc-resolve: Cannot resolve the name 'schemaB:objectInSchemaB' to a(n) 'type definition' component.
I can also build successfully if I omit the top level schema A, and start with just compiling schema B importing schema C. So again, the problem seems to be going more than one level deep with nested imports.
I'm stuck!
JAXB version:
Detected JAXB API version [2.2]. pluginArtifacts:[org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:maven-plugin:0.9.0:, org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-core:jar:0.9.0:compile, com.sun.org.apache.xml.internal:resolver:jar:20050927:compile, org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile, junit:junit:jar:4.8.1:compile, org.codehaus.plexus:plexus-utils:jar:1.5.15:compile, org.jvnet.jaxb2.maven2:maven-jaxb22-plugin:jar:0.9.0:compile, javax.xml.bind:jaxb-api:jar:2.2.7:compile, com.sun.xml.bind:jaxb-impl:jar:2.2.7:compile, com.sun.xml.bind:jaxb-core:jar:2.2.7:compile, com.sun.istack:istack-commons-runtime:jar:2.16:compile, com.sun.xml.fastinfoset:FastInfoset:jar:1.2.12:compile, javax.xml.bind:jsr173_api:jar:1.0:compile, com.sun.xml.bind:jaxb-xjc:jar:2.2.7:compile, org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.2:compile] specVersion:2.2
Below is my pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>Example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaIncludes>
<schemaInclude>**/*.xsd</schemaInclude>
</schemaIncludes>
<strict>true</strict>
<verbose>true</verbose>
<extension>true</extension>
<removeOldOutput>true</removeOldOutput>
<specVersion>2.2</specVersion>
<episode>true</episode>
<episodeFile>${project.build.directory}/generated-sources/xjc/META-INF/jaxb-example.episode</episodeFile>
</configuration>
<id>jaxb-generate-example</id>
</execution>
</executions>
<configuration>
<catalog>src/main/resources/jaxb/catalog.xml</catalog>
<catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
<forceRegenerate>true</forceRegenerate>
<generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>
<verbose>true</verbose>
<args>
<arg>-enableIntrospection</arg>
</args>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
"Schema A" below. If I comment out the baseSystemConfig object, then the schema compiles.
<?xml version="1.0"?>
<xsd:schema version="1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://ws.zwake.com/schema/zwakkiCentralCommon"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:zwakkiBase="http://ws.zwake.com/schema/zwakeBase"
jaxb:version="2.1">
<!-- Schema B import -->
<xsd:import namespace="http://ws.zwake.com/schema/zwakeBase" schemaLocation="../ZwakeBase/zwakeBase.xsd"/>
<xsd:annotation>
<xsd:appinfo>
<jaxb:globalBindings typesafeEnumMemberName="generateName"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="RetrieveBaseSystemConfigsRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="credentials" type="zwakkiBase:Credentials"/>
<xsd:element name="restrictToBaseSystemIds" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="RetrieveBaseSystemConfigsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="baseSystemConfig" type="zwakkiBase:ZwakeConfig" maxOccurs="unbounded"/>
<xsd:element name="responseStatus" type="zwakkiBase:SystemError" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>