2

I have an error when running the jaxb2-maven-plugin (2.5.0) with JDK11.

pom.xml :

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>xjc_test</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>../a/b/c/myschema.xsd</source>
                        </sources>
                        <clearOutputDir>false</clearOutputDir>
                        <outputDirectory />
                    </configuration>
                </execution>
            </executions>
</plugin>

error :

 [ERROR] null [-1,-1] 
org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'file:/home/userE/eclipse-workspace-201809/parent/testjaxb/home/userE/eclipse-workspace-201809/parent/a/b/c/myschema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.5.0:xjc (xjc_test) on project xxx:

[ERROR] +=================== [XJC Error]
[ERROR] |
[ERROR] | 0: file:/home/userE/eclipse-workspace-201809/parent/a/b/c/myschema.xsd
[ERROR] |
[ERROR] +=================== [End XJC Error]

If I put a wrong source path in the pom.xml it fails, so I can assume that it finds the correct .xsd file. I don't understand the schema_reference, where does it come from.

For info my .xsd looks like : (he's located on another project)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    ...
</xs:schema>
ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
E Kh
  • 105
  • 9

1 Answers1

0

try to put reference to basedir like so:

..    
<sources>                                
   <source>${project.basedir}/src/main/resources/your_folder/your_xsd.xsd</source>
</sources>
..
Michael Cauduro
  • 185
  • 1
  • 3
  • 16