mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
107 stars 77 forks source link

Xsd file path is not correctly transfered to xjc when project is a maven module #17

Closed vincentmonier closed 9 years ago

vincentmonier commented 9 years ago

Hi,

I've a maven multi-modules project, and one of my module generates classes based on a XSD schema. Generation is fine with 1.6 version of jaxb2-maven-plugin.

When I tried to use new 2.1 version of jaxb2-maven-plugin I get the following exception thrown by Xerces:

Caused by: java.io.FileNotFoundException: <path_to_my_project>/<parent_project>/src/main/resources/xsd/myXsd.xsd (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:622)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2279)

Which is normal since my XSD file is not located there. But my plugin configuration does have the correct path. Below is an extract of the pom located in my module project `̀``///pom.xml```

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <id>generation</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <configuration>
                            <arguments>
                                <argument>-Xfluent-api</argument>
                                <argument>-Xsetters</argument>
                                <argument>-Xsetters-mode=direct</argument>
                            </arguments>
                            <sources>
                                <source>src/main/resources/xsd/myXsd.xsd</source>
                            </sources>
                            <xjbSources>
                                <xjbSource>src/main/resources/xjb/myBinding.xjb</xjbSource>
                            </xjbSources>
                        <packageName>mypackage</packageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I guess the same problem will occur for the bindings

vincentmonier commented 9 years ago

I also have the same issue when I use the following configuration

<sources>
        <source>src/main/resources/xsd</source>
 </sources>

The plugin execution final trace shows the parameter is correctly given to plugin:

 +=================== [XJC Error]
[ERROR] |
[ERROR] | 0: file:<path_to_my_project>/<parent_project>/<my_xsd_module>/src/main/resources/xsd/myXsd.xsd
[ERROR] |
[ERROR] +=================== [End XJC Error]
ReneNieuwenhuis commented 9 years ago

looks like a duplicate of #5

zdharmawan commented 9 years ago

I am having the same issue, but for some reasons, this is only happening in Linux/Unix not when I am building on Windows. Any update on this issue?

zdharmawan commented 9 years ago

My bad this is now fixed in version 2.2

lennartj commented 9 years ago

Closing as a Duplicate.