title: Using XJB with jaxb2-maven-plugin
body: <p>I have a multi-module maven project in the following structure:</p>
  
  <pre><code>root-module
      |__module-a
      |    |__src
      |        |__main
      |            |__xsd
      |            |    |__my.xsd
      |            |__xjb
      |                 |__my.xjb
      |__module-b
  </code></pre>
  
  <p>The POM for root module simply aggregates module a and b (among other things):</p>
  
  <pre><code>&lt;project&gt;
    &lt;artifactId&gt;root-module&lt;/artifactId&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
    &lt;modules&gt;
      &lt;module&gt;module-a&lt;/module&gt;
      &lt;module&gt;module-b&lt;/module&gt;
    &lt;/modules&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>And the POM for module a is as follows (among other things):</p>
  
  <pre><code>&lt;project&gt;
    &lt;parent&gt;
      &lt;artifactId&gt;root-module&lt;/artifactId&gt;
    &lt;/parent&gt;
    &lt;artifactId&gt;module-a&lt;/artifactId&gt;
    &lt;properties&gt;
      &lt;my-definitions.xsd&gt;${basedir}/src/main/xsd/my.xsd&lt;/my-definitions.xsd&gt;
      &lt;my-bindings.xjb&gt;${basedir}/src/main/xjb/my.xjb&lt;/my-bindings.xjb&gt;
      &lt;my.output&gt;${basedir}/target/generated-sources/jaxb/my&lt;/my.output&gt;
    &lt;/properties&gt;
    &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;generate-my-classes&lt;/id&gt;
                          &lt;phase&gt;generate-sources&lt;/phase&gt;
                          &lt;goals&gt;&lt;goal&gt;xjc&lt;/goal&gt;&lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;sources&gt;&lt;source&gt;${my-definitions.xsd}&lt;/source&gt;&lt;/sources&gt;
                              &lt;xjbSources&gt;&lt;xjbSource&gt;${my-bindings.xjb}&lt;/xjbSource&gt;&lt;/xjbSources&gt;
                              &lt;outputDirectory&gt;${my.output}&lt;/outputDirectory&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>So when I run mvn at module-a, everything works fine and the build succeeds. But when I run it at root-module, I get an exception from the XJC plugin where it tries to find the bindings file under the root-module:</p>
  
  <pre><code>com.sun.istack.SAXParseException2; IOException thrown when processing "file:/home/root-module/src/main/xjb/my.xjb". Exception: java.io.FileNotFoundException: /home/root-module/src/main/xjb/my.xjb (The system cannot find the path specified).
  </code></pre>
  
  <p>What is interesting is, it is able to locate the XSD correctly:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.1:xjc (generate-my-classe) on project module-a:
  [ERROR] +=================== [XJC Error]
  [ERROR] |
  [ERROR] | 0: file:/home/root-module/module-a/src/main/xsd/my.xsd
  [ERROR] |
  [ERROR] +=================== [End XJC Error]
  </code></pre>
  
  <ul>
  <li>Any clues?</li>
  <li>Is this a configuration issue in the build script?</li>
  </ul>
  
  <p>Specifics of my build system:</p>
  
  <pre><code>Using Maven 3.2.5
  
  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
  &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;2.1&lt;/version&gt;
  </code></pre>
  
  <p>Referring JAXB2 Maven plugin documentation from <a href="http://www.mojohaus.org/jaxb2-maven-plugin/xjc-mojo.html" rel="nofollow">here</a>.
  Also searched few related questions on SO, but they do not explain my specific problem anywhere.</p>
  
  <p><strong>UPDATE:</strong> Looks like an <a href="https://github.com/mojohaus/jaxb2-maven-plugin/issues/5" rel="nofollow">open issue</a>. Keeping the thread open in case there is a workaround.</p>