highsource / jaxb-tools

The most advanced JAXB2 Maven Plugin for XML Schema compilation.
Other
431 stars 99 forks source link

Unable to resolve relative import located within same dependencyResource artifact #83

Open jpraet opened 8 years ago

jpraet commented 8 years ago

I'm trying to configure the plugin with a dependencyResource jar that contains 2 XSD. One XSD is importing the other with an specifying the relative path.

But the plugin cannot resolve the imported XSD:

[WARNING] Error while parsing schema(s).Location [ maven:XYZ:XYZ:xsd::!XYZ.xsd{15,114}]. org.xml.sax.SAXParseException; systemId: maven:XYZ:XYZ:xsd::!XYZ.xsd; lineNumber: 15; columnNumber: 114; schema_reference.4: Failed to read schema document '../../types/common/CommonV3.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. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:392) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4158) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:4153) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(XSDHandler.java:2486) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2183) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:2074) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:1004) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:616) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:613) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:572) at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538) at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:255) at com.sun.tools.xjc.reader.xmlschema.parser.SchemaConstraintChecker.check(SchemaConstraintChecker.java:111) at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:360) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174) at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119) at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40) at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:505) at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:328) ... Caused by: java.net.MalformedURLException: unknown protocol: maven at java.net.URL.(URL.java:600) at java.net.URL.(URL.java:490) at java.net.URL.(URL.java:439) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:620) at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189) at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:582) at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:685) at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(SchemaDOMParser.java:530) at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2171) ... 37 more

highsource commented 8 years ago

I'd need a reproducing test case for this please PR a test case here:

https://github.com/highsource/maven-jaxb2-plugin-support

under issues/gh83.

Thanks

This should actually work, I have quite a lot relative paths in projects like ogc-schemas.

On Fri, Jan 29, 2016 at 8:18 PM, jpraet notifications@github.com wrote:

I'm trying to configure the plugin with a dependencyResource jar that contains 2 XSD One XSD is importing the other with an specifying the relative path

But the plugin cannot resolve the imported XSD:

[WARNING] Error while parsing schema(s)Location [ maven:XYZ:XYZ:xsd::!XYZxsd{15,114}] orgxmlsaxSAXParseException; systemId: maven:XYZ:XYZ:xsd::!XYZxsd; lineNumber: 15; columnNumber: 114; schema_reference4: Failed to read schema document '//types/common/CommonV3xsd', 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 at comsunorgapachexercesinternalutilErrorHandlerWrappercreateSAXParseException(ErrorHandlerWrapperjava:203) at comsunorgapachexercesinternalutilErrorHandlerWrapperwarning(ErrorHandlerWrapperjava:99) at comsunorgapachexercesinternalimplXMLErrorReporterreportError(XMLErrorReporterjava:392) at comsunorgapachexercesinternalimplxstraversersXSDHandlerreportSchemaErr(XSDHandlerjava:4158) at comsunorgapachexercesinternalimplxstraversersXSDHandlerreportSchemaWarning(XSDHandlerjava:4153) at comsunorgapachexercesinternalimplxstraversersXSDHandlergetSchemaDocument1(XSDHandlerjava:2486) at comsunorgapachexercesinternalimplxstraversersXSDHandlergetSchemaDocument(XSDHandlerjava:2183) at comsunorgapachexercesinternalimplxstraversersXSDHandlerresolveSchema(XSDHandlerjava:2074) at comsunorgapachexercesinternalimplxstraversersXSDHandlerconstructTrees(XSDHandlerjava:1004) at comsunorgapachexercesinternalimplxstraversersXSDHandlerparseSchema(XSDHandlerjava:616) at comsunorgapachexercesinternalimplxsXMLSchemaLoaderloadSchema(XMLSchemaLoaderjava:613) at comsunorgapachexercesinternalimplxsXMLSchemaLoaderloadGrammar(XMLSchemaLoaderjava:572) at comsunorgapachexercesinternalimplxsXMLSchemaLoaderloadGrammar(XMLSchemaLoaderjava:538) at comsunorgapachexercesinternaljaxpvalidationXMLSchemaFactorynewSchema(XMLSchemaFactoryjava:255) at comsuntoolsxjcreaderxmlschemaparserSchemaConstraintCheckercheck(SchemaConstraintCheckerjava:111) at comsuntoolsxjcModelLoaderloadXMLSchema(ModelLoaderjava:360) at comsuntoolsxjcModelLoaderload(ModelLoaderjava:174) at comsuntoolsxjcModelLoaderload(ModelLoaderjava:119) at orgjvnetmjiipv_2_2XJC22MojoloadModel(XJC22Mojojava:50) at orgjvnetmjiipv_2_2XJC22MojodoExecute(XJC22Mojojava:40) at orgjvnetmjiipv_2_2XJC22MojodoExecute(XJC22Mojojava:28) at orgjvnetjaxb2maven2RawXJC2MojodoExecute(RawXJC2Mojojava:505) at orgjvnetjaxb2maven2RawXJC2Mojoexecute(RawXJC2Mojojava:328)

Caused by: javanetMalformedURLException: unknown protocol: maven at javanetURL(URLjava:600) at javanetURL(URLjava:490) at javanetURL(URLjava:439) at comsunorgapachexercesinternalimplXMLEntityManagersetupCurrentEntity(XMLEntityManagerjava:620) at comsunorgapachexercesinternalimplXMLVersionDetectordetermineDocVersion(XMLVersionDetectorjava:189) at comsunorgapachexercesinternalimplxsoptiSchemaParsingConfigparse(SchemaParsingConfigjava:582) at comsunorgapachexercesinternalimplxsoptiSchemaParsingConfigparse(SchemaParsingConfigjava:685) at comsunorgapachexercesinternalimplxsoptiSchemaDOMParserparse(SchemaDOMParserjava:530) at comsunorgapachexercesinternalimplxstraversersXSDHandlergetSchemaDocument(XSDHandlerjava:2171) 37 more

— Reply to this email directly or view it on GitHub https://github.com/highsource/maven-jaxb2-plugin/issues/83.

jpraet commented 8 years ago

test case: https://github.com/highsource/maven-jaxb2-plugin-support/pull/1

highsource commented 8 years ago

Here's a workaround:

https://github.com/highsource/maven-jaxb2-plugin-support/commit/e5d7434b66d6edb09c4eec2f158c67d35ea6ae6e

DiabolusExMachina commented 7 years ago

Hi,

will this anytime soon work out of the box? We have the same problem. We have a WSDL multiple nested relative imports of XSD Files in a complex folder structure (The files are generated).

I'm not sure if your workaround will work in such a scenario.

DranonJoD commented 6 years ago

Still no fix?

highsource commented 6 years ago

I'm not sure, I thought I have fixed it. I'll check.

delanym commented 3 years ago

Today my build failed temporarily. Even though a local schemaLocation is set, the plugin went online, and failed because presumably the remote server was down.

Failed to read schema document 'xmldsig-core-schema.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>.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException (ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning (ErrorHandlerWrapper.java:99)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (XMLErrorReporter.java:392)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr (XSDHandler.java:4154)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning (XSDHandler.java:4149)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1 (XSDHandler.java:2491)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument (XSDHandler.java:2193)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema (XSDHandler.java:2084)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees (XSDHandler.java:1014)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema (XSDHandler.java:625)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema (XMLSchemaLoader.java:610)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar (XMLSchemaLoader.java:569)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar (XMLSchemaLoader.java:535)
    at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema (XMLSchemaFactory.java:254)
    at com.sun.tools.xjc.reader.xmlschema.parser.SchemaConstraintChecker.check (SchemaConstraintChecker.java:111)
    at com.sun.tools.xjc.ModelLoader.loadXMLSchema (ModelLoader.java:342)
    at com.sun.tools.xjc.ModelLoader.load (ModelLoader.java:162)
    at com.sun.tools.xjc.ModelLoader.load (ModelLoader.java:117)
    at org.jvnet.mjiip.v_2_3.XJC23Mojo.loadModel (XJC23Mojo.java:50)
    at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute (XJC23Mojo.java:40)
    at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute (XJC23Mojo.java:28)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute (RawXJC2Mojo.java:478)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute (RawXJC2Mojo.java:320)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/2001/datatypes.dtd
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1900)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1498)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity (XMLEntityManager.java:647)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity (XMLEntityManager.java:1304)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity (XMLEntityManager.java:1240)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.startPE (XMLDTDScannerImpl.java:741)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.skipSeparator (XMLDTDScannerImpl.java:2110)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls (XMLDTDScannerImpl.java:2073)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDExternalSubset (XMLDTDScannerImpl.java:306)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch (XMLDocumentScannerImpl.java:1174)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next (XMLDocumentScannerImpl.java:1045)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next (XMLDocumentScannerImpl.java:933)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next (XMLDocumentScannerImpl.java:602)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next (XMLNSDocumentScannerImpl.java:112)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument (XMLDocumentFragmentScannerImpl.java:505)
    at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse (SchemaParsingConfig.java:630)
    at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse (SchemaParsingConfig.java:686)
    at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse (SchemaDOMParser.java:530)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument (XSDHandler.java:2181)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema (XSDHandler.java:2084)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees (XSDHandler.java:1014)
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema (XSDHandler.java:625)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema (XMLSchemaLoader.java:610)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar (XMLSchemaLoader.java:569)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar (XMLSchemaLoader.java:535)
    at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema (XMLSchemaFactory.java:254)
    at com.sun.tools.xjc.reader.xmlschema.parser.SchemaConstraintChecker.check (SchemaConstraintChecker.java:111)
    at com.sun.tools.xjc.ModelLoader.loadXMLSchema (ModelLoader.java:342)
    at com.sun.tools.xjc.ModelLoader.load (ModelLoader.java:162)
    at com.sun.tools.xjc.ModelLoader.load (ModelLoader.java:117)
    at org.jvnet.mjiip.v_2_3.XJC23Mojo.loadModel (XJC23Mojo.java:50)
    at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute (XJC23Mojo.java:40)
    at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute (XJC23Mojo.java:28)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute (RawXJC2Mojo.java:478)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute (RawXJC2Mojo.java:320)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:190)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)
delanym commented 3 years ago

I had a different issue, caused by the DOCTYPE declaration. Only solution was to remove it https://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd Same issue in the cxf-xjc-plugin.