title: WSDLException faultCode=PARSER_ERROR - When using schemaLocation: MyService?xsd=myschema.xsd
body: <p>I'm using a 3rd party <code>WSDL</code> that includes a <code>XSD</code> definition. I've downloaded the <code>WSDL</code> and <code>XSD</code> and placed them in local folders: <code>${project.basedir}/src/main/resources/wsdl/</code> and <code>${project.basedir}/src/main/resources/xsd/</code> respectively.</p>
  <p>The start of the <code>WSDL</code> file locks like this:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;definitions name=&quot;MyService&quot; targetNamespace=&quot;http://com.foo.crud&quot; xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot; xmlns:crud=&quot;http://com.foo.crud&quot; xmlns:tns=&quot;http://com.foo.schema&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;&gt;
  &lt;documentation&gt;MyService Ver. 1.5&lt;/documentation&gt;
      &lt;types&gt;
          &lt;xsd:schema&gt;
              &lt;xsd:import namespace=&quot;http://com.foo.schema&quot; schemaLocation=&quot;MyService?xsd=myschema.xsd&quot;/&gt;
          &lt;/xsd:schema&gt;
      &lt;/types&gt;
  ...
  </code></pre>
  <p>If I run the code as it is (see below for the configuration of the <code>cxf-codegen-plugin</code>), <code>maven</code> throws an error:</p>
  <pre><code>faultCode=PARSER_ERROR: Problem parsing 'MyService?xsd=myschema.xsd'.: java.io.FileNotFoundException: /home/user/my-application/target/MyService (No such file or directory)
  </code></pre>
  <p>So it seems that the <code>cxf-codegen-plugin</code> fails to interprets the <code>schemaLocation</code> correct, it is looking for <code>MyService</code> instead of <code>myschema.xsd</code>.</p>
  <p>I can &quot;fix&quot; the problem by changing the specified location from <code>schemaLocation=&quot;MyService?xsd=myschema.xsd&quot;</code> to <code>schemaLocation=&quot;../xsd/myschema.xsd&quot;</code>.</p>
  <p><strong>But</strong> somehow it feels wrong to edit a provided <code>WSDL</code> manually.</p>
  <p>I'm using:</p>
  <ul>
  <li><code>maven : 3.6.0</code></li>
  <li><code>cxf-codegen-plugin : 3.3.7</code></li>
  <li><code>java : 11.0.7</code></li>
  </ul>
  <p>And finally my plugin configuration:</p>
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
      &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;generate-sources&lt;/id&gt;
              &lt;phase&gt;generate-sources&lt;/phase&gt;
              &lt;configuration&gt;
                  &lt;sourceRoot&gt;${project.build.directory}/generated-sources/cxf&lt;/sourceRoot&gt;
                  &lt;wsdlOptions&gt;
                      &lt;wsdlOption&gt;
                          &lt;wsdl&gt;${project.basedir}/src/main/resources/wsdl/MyService.wsdl&lt;/wsdl&gt;
                          &lt;wsdlLocation&gt;classpath:wsdl/MyService.wsdl&lt;/wsdlLocation&gt;
                      &lt;/wsdlOption&gt;
                  &lt;/wsdlOptions&gt;
              &lt;/configuration&gt;
              &lt;goals&gt;
                  &lt;goal&gt;wsdl2java&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  <p>I've tried adding a hint where to find the <code>XSD</code> file:</p>
  <pre><code>&lt;extraargs&gt;
      &lt;extraarg&gt;-catalog&lt;/extraarg&gt;
      &lt;extraarg&gt;${basedir}/src/main/resources/xsd/myschema.xsd&lt;/extraarg&gt;
  &lt;/extraargs&gt;
  </code></pre>
  <p>But of course if the name is not correctly parsed this does not help.</p>
  <p>So if anybody knows how to address this issue, any help is highly appreciated!</p>
  <hr />
  <p>Detailed Stacktrace:</p>
  <pre><code>[INFO] 20:14:21.675 [main] DEBUG org.apache.cxf.resource.DefaultResourceManager - resolving resource &lt;MyService?xsd=myschema.xsd&gt; as stream 
  [INFO] 20:14:21.676 [main] DEBUG org.apache.cxf.resource.DefaultResourceManager - resolving resource &lt;MyService?xsd=myschema.xsd&gt; type &lt;class java.net.URL&gt;
  [WARNING] Exception in thread &quot;main&quot; org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition file:/home/user/my-application/src/main/resources/wsdl/MyService.wsdl: WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'MyService?xsd=myschema.xsd'.: java.io.FileNotFoundException: /home/user/my-application/target/MyService (No such file or directory)
  [WARNING]   at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
  [WARNING]   at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:105)
  [WARNING]   at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
  [WARNING]   at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
  [WARNING]   at org.apache.cxf.maven_plugin.wsdl2java.ForkOnceWSDL2Java.main(ForkOnceWSDL2Java.java:51)
  [WARNING] Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition file:/home/user/my-application/src/main/resources/wsdl/MyService.wsdl: WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'MyService?xsd=myschema.xsd'.: java.io.FileNotFoundException: /home/user/my-application/target/MyService (No such file or directory)
  [WARNING]   at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:99)
  [WARNING]   at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:71)
  [WARNING]   at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
  [WARNING]   at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
  [WARNING]   at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:187)
  [WARNING]   at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:156)
  [WARNING]   at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:404)
  [WARNING]   ... 4 more
  [WARNING] Caused by: javax.wsdl.WSDLException: WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'MyService?xsd=myschema.xsd'.: java.io.FileNotFoundException: /home/user/my-application/target/MyService (No such file or directory)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:830)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:654)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:610)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(WSDLReaderImpl.java:320)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2352)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2338)
  [WARNING]   at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:255)
  [WARNING]   at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:165)
  [WARNING]   at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:80)
  [WARNING]   ... 10 more
  [WARNING] Caused by: java.io.FileNotFoundException: /home/user/my-application/target/MyService (No such file or directory)
  [WARNING]   at java.base/java.io.FileInputStream.open0(Native Method)
  [WARNING]   at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
  [WARNING]   at java.base/java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:157)
  [WARNING]   at java.base/java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:112)
  [WARNING]   at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
  [WARNING]   at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:652)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:150)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:860)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246)
  [WARNING]   at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
  [WARNING]   at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
  [WARNING]   ... 19 more
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time:  9.889 s
  [INFO] Finished at: 2020-08-04T20:14:21+02:00
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.3.7:wsdl2java (generate-sources) on project my-application: 
  [ERROR] Exit code: 1
  [ERROR] Command line was: /usr/local/share/jdk-11.0.7/bin/java --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED -jar /tmp/cxf-tmp-3258269347027548146/cxf-codegen1999716177968029181.jar /tmp/cxf-tmp-3258269347027548146/cxf-w2j14505354483396894904args
  </code></pre>