Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Class Error due to XJC double source Root #91

Closed
JulienHoullier opened this issue Jul 7, 2017 · 4 comments
Closed

Duplicate Class Error due to XJC double source Root #91

JulienHoullier opened this issue Jul 7, 2017 · 4 comments
Assignees
Milestone

Comments

@JulienHoullier
Copy link

JulienHoullier commented Jul 7, 2017

Issue on version 2.3.1, no issue on version 2.2

This issue happens on our Jenkins CI plateform,
The runner try to build project files which where on /var/jenkins/workspace/. The workspace directory is a link to a mounted directory shared by Runners /u/jenkins

On our pom.xml the xjc goals confiuration is :

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <configuration>
                    <outputDirectory>${project.build.directory}/generated/jaxb</outputDirectory>
                    <sources>
                        <source>${xsd.dir}</source>
                    </sources>
                    <packageName>com.test.xml</packageName>
                </configuration>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

where xsd.dir is set to:

src/main/resources/xsd

And with -X logs XJC trace:

[DEBUG]
+=================== [13 XJC Arguments]
|
| [0]: -xmlschema
| [1]: -encoding
| [2]: UTF-8
| [3]: -p
| [4]: com.test.xml
| [5]: -d
| [6]: /var/jenkins/workspace/project/target/generated/jaxb
| [7]: -classpath
| [8]: /var/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.3.3_autoinstall/conf/logging/
| [9]: -extension
| [10]: -episode
| [11]: /u/jenkins/project/target/generated/jaxb/META-INF/sun-jaxb.episode
| [12]: project/src/main/resources/xsd/<xsd_name>.xsd
|
+=================== [End 13 XJC Arguments]
and on System Properties traces:
[PWD]: /var/jenkins
[user.dir]: /u/jenkins/project
[basedir]: /u/jenkins/project

I suspect here that either ${project.build.directory} is not resolved properly, or relative src/main/resource/xsd is not resolved the same as ${basedir}/src/main/resources/xsd

Then on later compile phase trace with -X:

[DEBUG] Source roots:
[DEBUG] /var/jenkins/workspace/project/src/main/java
[DEBUG] /var/jenkins/workspace/project/target/generated/jaxb
[DEBUG] /u/jenkins/project/target/generated/jaxb

The last two folder are in fact the same, which leads to compilation errors:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /var/jenkins/workspace/project/target/generated/jaxb/com/test/xml/Class1Xml.java:[42,8] duplicate class: com.test.xml.Class1Xml.java
...

@stklcode
Copy link

stklcode commented Apr 9, 2018

Any updates on that?

I got the same issue on a Jenkins istance.

[DEBUG] Source directories: [/var/lib/jenkins/jobs/project/workspace/foo/bar/src/main/java
/var/lib/jenkins/jobs/project/workspace/foo/bar/target/generated-sources/jaxb
/my/mount/jenkins/jobs/projects/workspace/foo/bar/target/generated-sources/jaxb]

where /var/lib/jenkins is a symlink to /my/mount/jenkins. No output directory specified in the pom.xml.

Interesting point: the build runs fine when executing the mvn command manually in the same container (workspace not cleaned after failure).

Also runs fine when there is no symlink present, so I'd suspect the problem,

Did I miss any flag to prevent that issue or is this indeed a bug?

@lennartj lennartj self-assigned this May 30, 2018
@lennartj
Copy link
Member

It seems that the plugin does not handle symlinks properly here (i.e. regards the symlinked directory in the same way as a non-symlinked one).

Does the same issue persist in version 2.4?

@stklcode
Copy link

stklcode commented May 30, 2018

Does the same issue persist in version 2.4?

Apparently not 👍 Just compiled a minimal test example that fails using 2.3.1, but succeeds with 2.4. Thanks for that!

I guess it has been fixed with #56, right?

@lennartj
Copy link
Member

Indeed.

@lennartj lennartj added this to the Release 2.4.1 milestone May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants