title: JAXB - The schemaBindings customization is not associated with any schema element
body: <p>I'm trying to generated Java classes from a set of XSD files using the Maven XJC plugin with a  custom binding. The customization is added to <a href="https://stackoverflow.com/questions/892298/prefixing-jaxb-generated-classes#answer-903629">prefix JAXB generated classes</a>. When the maven build runs, however, the XJC plugin doesn't seem to recognize the <code>schemaBindings</code> element and throws the exception as under.</p>
  
  <pre><code>[ERROR] Error while parsing schema(s).Location [ file:/C:/blah/bindings.xjb{5,25}].
  com.sun.istack.SAXParseException2: The "jaxb:schemaBindings" customization is no
  t associated with any schema element.
          at com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Intern
  alizer.java:632)
          at com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Intern
  alizer.java:626)
          at com.sun.tools.xjc.reader.internalizer.Internalizer.move(Internalizer.
  java:451)
          at com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internal
  izer.java:160)
          at com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internal
  izer.java:109)
          at com.sun.tools.xjc.reader.internalizer.DOMForest.transform(DOMForest.j
  ava:449)
          at com.sun.tools.xjc.ModelLoader.buildDOMForest(ModelLoader.java:345)
          at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:377)
          at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
          at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
          at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:45)
          at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:35)
          at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:22)
          at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:282)
          at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:147)
          at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
  nManager.java:490)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
  ultLifecycleExecutor.java:694)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
  fecycle(DefaultLifecycleExecutor.java:556)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
  ltLifecycleExecutor.java:535)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
  dleFailures(DefaultLifecycleExecutor.java:387)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
  ts(DefaultLifecycleExecutor.java:348)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
  fecycleExecutor.java:180)
          at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
          at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
          at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
          at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:6
  0)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
  java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
  sorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
          at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
          at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
  
          at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
  </code></pre>
  
  <p>The bindings.jxb is as follows.</p>
  
  <pre><code>&lt;jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
             jaxb:version="2.1" schemaLocation="blah.xsd"&gt;      
      &lt;jaxb:schemaBindings&gt;
          &lt;jaxb:nameXmlTransform&gt;
                &lt;jaxb:elementName suffix="Type"/&gt;
          &lt;/jaxb:nameXmlTransform&gt; 
      &lt;/jaxb:schemaBindings&gt;
  &lt;/jaxb:bindings&gt;
  </code></pre>
  
  <p>The following plugins are used for the generating the Java Classes. Pasting the relevant <code>mvn</code> snippet here.</p>
  
  <pre><code>&lt;plugin&gt;   
  
      &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
  
      &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
  
      &lt;version&gt;0.8.0&lt;/version&gt;
  
          &lt;executions&gt;
  
              &lt;execution&gt;
  
                  &lt;goals&gt;
  
                      &lt;goal&gt;generate&lt;/goal&gt;
  
                  &lt;/goals&gt;
              &lt;/execution&gt;
  
          &lt;/executions&gt;
  
          &lt;dependencies&gt;
  
              &lt;dependency&gt;
  
                  &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
  
                  &lt;artifactId&gt;jaxb-xjc&lt;/artifactId&gt;
  
                  &lt;version&gt;2.2.6&lt;/version&gt;
  
              &lt;/dependency&gt;
  
              &lt;dependency&gt;
  
                  &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
  
                  &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
  
                  &lt;version&gt;2.2.6&lt;/version&gt;
  
              &lt;/dependency&gt;
  
          &lt;/dependencies&gt;
      &lt;configuration&gt;
  
                                 &lt;schemaDirectory&gt;./src/main/resources&lt;/schemaDirectory&gt;
  
                      &lt;includeBindings&gt;
                          &lt;includeBinding&gt;**/*.xjb&lt;/includeBinding&gt;
                      &lt;/includeBindings&gt;
                      &lt;extension&gt;true&lt;/extension&gt;
  
                  &lt;/configuration&gt;
  
              &lt;/plugin&gt;
  </code></pre>
  
  <p>The <a href="http://www.java.net/node/660051" rel="nofollow noreferrer">only other discussion I could find on this issue revolves about JAX-WS</a> which I don't use as there's no WSDL files involved here. It's all XSD files here.</p>
  
  <p>I don't see why this error has to occur because the JAXB's <code>binding.xsd</code> file indeed defines the <code>schemaBindings</code> element as seen below.</p>
  
  <pre><code>&lt;xs:element name="schemaBindings" substitutionGroup="jaxb:declaration"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element minOccurs="0" ref="jaxb:package"/&gt;
          &lt;xs:element minOccurs="0" ref="jaxb:nameXmlTransform"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:attribute name="map" type="xs:boolean" /&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>Any hints on this problem would be very much appreciated. Please let me know if more inputs are needed. Thanks!</p>
  
  <p>EDIT:
  A lot of people on the Internet seem to have used the schemaBindings without any issues. May be this is an issue with the dependencies mentioned in the question?</p>