jaxb2-maven-plugin
jaxb2-maven-plugin copied to clipboard
XJC FileNotFoundException when space is in path
Env
| Name | Version |
|---|---|
| Maven | 3.3.9 |
| Java | Oracle JDK 8_181 |
| jaxb2-maven-plugin | 2.4 |
Issue
The problem comes from our Build-Server where the job-name should include a space char.
Error-Stack of the failed build:
Click for Stack
00:02:57.644 [ERROR] null [-1,-1]
00:02:57.644 org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'file:/ciwork/jenkins/workspace/proj/project%20test/ciwork/jenkins/workspace/proj/project%20test/mvn-module/src/main/resources/xsd/name.xjb', 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>.
00:02:57.644 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
00:02:57.644 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
00:02:57.644 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
00:02:57.644 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:306)
00:02:57.644 at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4158)
00:02:57.644 at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:4141)
00:02:57.644 at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(XSDHandler.java:2480)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2308)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:565)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:610)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:569)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:535)
00:02:57.645 at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:254)
00:02:57.645 at com.sun.tools.xjc.reader.xmlschema.parser.SchemaConstraintChecker.check(SchemaConstraintChecker.java:111)
00:02:57.645 at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:342)
00:02:57.645 at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:162)
00:02:57.645 at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:117)
00:02:57.645 at com.sun.tools.xjc.Driver.run(Driver.java:354)
00:02:57.645 at org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo.performExecution(AbstractJavaGeneratorMojo.java:468)
00:02:57.645 at org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute(AbstractJaxbMojo.java:315)
00:02:57.645 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
00:02:57.645 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
00:02:57.645 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
00:02:57.645 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
00:02:57.645 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
00:02:57.645 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
00:02:57.645 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
00:02:57.645 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
00:02:57.645 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
00:02:57.645 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
00:02:57.645 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
00:02:57.645 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
00:02:57.645 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
00:02:57.645 at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
00:02:57.645 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
00:02:57.645 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
00:02:57.645 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
00:02:57.645 at java.lang.reflect.Method.invoke(Method.java:498)
00:02:57.645 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
00:02:57.645 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
00:02:57.645 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
00:02:57.645 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
00:02:57.645 Caused by: java.io.FileNotFoundException: /ciwork/jenkins/workspace/proj/project test/ciwork/jenkins/workspace/proj/project test/mvn-module/src/main/resources/xsd/name.xjb (No such file or directory)
00:02:57.645 at java.io.FileInputStream.open0(Native Method)
00:02:57.645 at java.io.FileInputStream.open(FileInputStream.java:195)
00:02:57.645 at java.io.FileInputStream.<init>(FileInputStream.java:138)
00:02:57.645 at java.io.FileInputStream.<init>(FileInputStream.java:93)
00:02:57.645 at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
00:02:57.645 at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:623)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)
00:02:57.645 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:806)
00:02:57.645 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
00:02:57.645 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
00:02:57.645 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
00:02:57.645 at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
00:02:57.645 at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2280)
00:02:57.645 ... 34 more
Reason
I have seen something in the log that might be the fault for this:
00:02:57.379 [DEBUG]
00:02:57.379 +=================== [20 XJC Arguments]
00:02:57.379 |
00:02:57.379 | [0]: -xmlschema
00:02:57.379 | [1]: -extension
00:02:57.379 | [2]: -httpproxy
00:02:57.379 | [3]: xxxxxxx
00:02:57.379 | [4]: -encoding
00:02:57.379 | [5]: UTF-8
00:02:57.379 | [6]: -p
00:02:57.379 | [7]: xxxxxxx
00:02:57.379 | [8]: -target
00:02:57.379 | [9]: 2.1
00:02:57.379 | [10]: -d
00:02:57.379 | [11]: /ciwork/jenkins/workspace/proj/project test/mvn-module/target/generated-sources/jaxb
00:02:57.379 | [12]: -episode
00:02:57.379 | [13]: /ciwork/jenkins/workspace/proj/project test/mvn-module/target/generated-sources/jaxb/META-INF/JAXB/episode_xjc.xjb
00:02:57.379 | [14]: -b
00:02:57.379 | [15]: /ciwork/jenkins/workspace/proj/project test/mvn-module/src/main/resources/xsd/name.xsd
00:02:57.379 | [16]: -b
00:02:57.379 | [17]: /ciwork/jenkins/workspace/proj/project test/mvn-module/src/main/resources/xsd/name.xjb
00:02:57.379 | [18]: ciwork/jenkins/workspace/proj/project%20test/mvn-module/src/main/resources/xsd/name.xjb
00:02:57.379 | [19]: ciwork/jenkins/workspace/proj/project%20test/mvn-module/src/main/resources/xsd/name.xsd
00:02:57.379 |
00:02:57.379 +=================== [End 20 XJC Arguments]
It looks really weird that the -b parameter is twice in there and the paths are formatted differently (first without %20 and then the last 2 are with it)
Here are the arguments for a successful build (replaced the whitespace with _):
[2019-12-11T09:51:40.609Z] [DEBUG]
[2019-12-11T09:51:40.609Z] +=================== [17 XJC Arguments]
[2019-12-11T09:51:40.609Z] |
[2019-12-11T09:51:40.609Z] | [0]: -xmlschema
[2019-12-11T09:51:40.609Z] | [1]: -extension
[2019-12-11T09:51:40.609Z] | [2]: -httpproxy
[2019-12-11T09:51:40.609Z] | [3]: xxxxxxxxxx
[2019-12-11T09:51:40.609Z] | [4]: -encoding
[2019-12-11T09:51:40.609Z] | [5]: UTF-8
[2019-12-11T09:51:40.609Z] | [6]: -p
[2019-12-11T09:51:40.609Z] | [7]: xxxxxxxxxx
[2019-12-11T09:51:40.609Z] | [8]: -target
[2019-12-11T09:51:40.609Z] | [9]: 2.1
[2019-12-11T09:51:40.609Z] | [10]: -d
[2019-12-11T09:51:40.609Z] | [11]: /ciwork/jenkins/workspace/proj/project_test/mvn-module/target/generated-sources/jaxb
[2019-12-11T09:51:40.609Z] | [12]: -episode
[2019-12-11T09:51:40.609Z] | [13]: /ciwork/jenkins/workspace/proj/project_test/mvn-module/target/generated-sources/jaxb/META-INF/JAXB/episode_xjc.xjb
[2019-12-11T09:51:40.609Z] | [14]: -b
[2019-12-11T09:51:40.609Z] | [15]: /ciwork/jenkins/workspace/proj/project_test/mvn-module/src/main/resources/xsd/name.xjb
[2019-12-11T09:51:40.609Z] | [16]: mvn-module/src/main/resources/xsd/name.xsd
[2019-12-11T09:51:40.609Z] |
[2019-12-11T09:51:40.609Z] +=================== [End 17 XJC Arguments]
It is generally a bad idea to have spaces in paths for the repositories where you keep the source code. A quick and decently stable workaround for this is simply to not have whitespace in your paths.
I mean that not having a space in the path is a fast solution is nothing we have to talk about. Its just stupid, because I cant change the display name for a Jenkins Pipeline so now I am forced to have a _ in my name which just looks bad.
Also I dont think this would be that hard to fix for someone familiar with this source code.
Facing the same issue, having to revert to 1.6, which does not have this problem.
Same issue here, build failed on Jenkins. I'm using 2.5.0 version of the plugin. I had to rename "Run integration tests" to ugly "Run_integration_tests".
@lennartj - I can't see any reason, why having spaces in a source code repo path would have to be generally a bad idea.