Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven jaxb2:xjc failing to generate code

I have added the following plugin into the Maven build in pom.xml

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>xjc</goal>
            </goals>
            <configuration> 
                <extension>true</extension>                             
                <clearOutputDir>false</clearOutputDir>
                <schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
                <schemaFiles>myapp.xsd</schemaFiles>                                                        
                <outputDirectory>${basedir}/src/main/java</outputDirectory>         
                <bindingDirectory>src/main/resources/xsd</bindingDirectory>     
                <bindingFiles>myapp-bindings.xjb</bindingFiles>
            </configuration>
        </execution>
    </executions>                       

</plugin>

Following is the build error.

[INFO] Ignored given or default xjbSources [C:\WorkSpace\MyApp\src\main\xjb], since it is not an existent file or directory.
[INFO] Ignored given or default sources [C:\WorkSpace\MyApp\src\main\xsd], since it is not an existent file or directory.
[WARNING] No XSD files found. Please check your plugin configuration.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.273s
[INFO] Finished at: Tue May 12 16:24:26 EDT 2015
[INFO] Final Memory: 9M/124M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "dev-artifactory" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.1:xjc (default) on project pml-jasypt-authentication-service: MojoExecutionException: NoSchemasException -> [Help 1]

I am confused, why is the plugin not referring to the paths and files specified in the configuration.

like image 534
user1760178 Avatar asked May 12 '15 20:05

user1760178


3 Answers

Version 2.1 has changed how sources are specified

http://mojo.codehaus.org/jaxb2-maven-plugin/xjc-mojo.html#sources

e.g

<configuration>
...
  <sources>
     <source>some/explicit/relative/file.xsd</source>
     <source>/another/absolute/path/to/a/specification.xsd</source>
     <source>a/directory/holding/xsds</source>
 </sources>
</configuration>

I'm having a whole world of other problems so sticking with 1.6 as jshark suggested is a good plan

like image 171
David Kerwick Avatar answered Sep 27 '22 22:09

David Kerwick


version 2.1 has a bug.

You can use <version>2.2</version> with the new syntax:

<configuration>
...
  <sources>
     <source>some/explicit/relative/file.xsd</source>
     <source>/another/absolute/path/to/a/specification.xsd</source>
     <source>a/directory/holding/xsds</source>
 </sources>
</configuration>

You can use <version>1.6</version> with the old syntax:

<configuration>
    ...
    <schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
    <schemaFiles>myapp.xsd</schemaFiles> 
</configuration>
like image 39
Stéphane GRILLON Avatar answered Sep 27 '22 23:09

Stéphane GRILLON


I had the same problem today, and resolved it by putting:

<version>1.6</version>

on the plugin definition (which is in general good practice to do)

like image 41
jshark Avatar answered Sep 28 '22 00:09

jshark