mojohaus / jaxb2-maven-plugin

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

Incorrect $basedir calculation between Windows & Linux #150

Open class101 opened 4 years ago

class101 commented 4 years ago

We have found few issues in jaxb2-maven-plugin with both latest version 2.5.0 and 2.4 that makes it unable to find XSD files in some situations.

We are downgrading to 2.3.1 were we are unable to reproduce the issues

Informations:

We have a multi maven project with the following supported mode of build:

10/29/19, 8:42:28 PM GMT: [ERROR] null [-1,-1] schema_reference.4: Failed to read schema document 'file:/root/eclipse-201909/root/0src/......', 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>. 10/29/19, 8:42:28 PM GMT: [DEBUG] Accepted configured sources [/root/0src/...xsd] _As you see my sources are in /root/0src/ but the plugin look at some point for /root/0src/_

We had previously another problem specific under Linux by asking the schemagen goal to look for a *.java files with a relative folder change "../../" , the plugin has always removed the first / of the generated absolute path at some point and this lead to a similar issue than /etc != etc.

We solved it by using the dependency plugin and the local repo rather than relative paths that is anyway bad practice, but I believe with experienced a similar issue.

Yet I'm out of idea, I'm been testing relative, absolute paths, $basedir, $project.build.directory, pluginManagements conf, nothing worked except downgrading to the 2.3.1 version of jaxb2-maven-plugin

We are also using jaxws-maven-plugin under Windows & Linux but we never experienced such troubles setting it up.

Blocker issue here.

bergert commented 4 years ago

maybe related to https://github.com/mojohaus/jaxb2-maven-plugin/issues/153

JakesIV commented 4 years ago

Not sure from the description if my problem is related but when using variables to get to WSDL path on Windows machines it seems like the plugin then has issues converting the String to a URL. The error is "Could not create the URI from string" I would use this

${project.basedir}/src/main/resources/templates/BureauEnqInfo.wsdl--> The project.basedir would be something like "C:\myprojects\thisproject\" When looking at the compile it would look like this C:\myprojects\thisproject\src/main/resources/templates/BureauEnqInfo.wsdl--> The process then fails on error "Could not create the URI from string" When I then hardcode the location with the forward slashes then it works C:/myprojects/thisproject/src/main/resources/templates/BureauEnqInfo.wsdl--> It does not seem like the function used to convert the string to a URI is windows compliant. Surely it should know that backslashes are used on windows. As we do not formulate the variable project.basedir but its done by Spring boot it would be highly appreciated if this could be rectified in this plugin.
MarkusRohlof commented 4 years ago

Minimal project structure to reproduce:

test
|
|-- parent
|    |--pom.xml
|
|-- sub
     |--pom.xml
     |--src/main/resources/schema.xsd

In which parent is a multi module project and sub uses the jaxb2-maven-plugin.

minimal-project.zip

jjromannet commented 3 years ago

Workaround for windows would be to hardcode schema url like this (note file:/// prefix): `

file:///c:/workspace/projects/some-project/src/main/schemas/my.wsdl
                            </schema>`
doggy-dev commented 1 year ago

I have the same problem as class101 on a Mac. Is it possible to cherry-pick 41c629cd585a0664c8e84569b68457cb8586c31c on a new branch from the release 2.5.0 and release an official 2.5.1 version with the fix?

doggy-dev commented 1 year ago

Hello @lennartj, I asked a month ago if a fixed version 2.5.1 could be released but I've got no answer yet. Can you please tell me who should I ask directly with a release request?

bergert commented 1 year ago

For me, this is resolved with jaxb2 v3.1.0(finally!)

doggy-dev commented 1 year ago

Version 3 generates classes with dependecies on the package jakarta. We're not ready to move to jakarta yet. For anyone else that is having problems of generating java classes in Eclipse - we've migrated to org.jvnet.jaxb2.maven2: maven-jaxb2-plugin:0.15.2. It works great.