Search code examples
deploymentpathwsdlmule

Mule - Exported project - Error java.io.FileNotFoundException


I have exported my mule project which contains a WSDL file in src.main.resources/wsdl-request.

The type of export is AnyPoint Studio Project to AnyPoint Deployable Archive.

The problem is that when I execute the deployable archive in the server it return this error:

Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'file:/C:/Users/usrAdmin/AnypointStudio/workspace/mule-project-test/src/main/resources/wsdl-test/Request.wsdl'. (The system cannot find the path specified)
    at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:249)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:192)
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
    ... 54 more
Caused by: java.io.FileNotFoundException: C:\Users\usrAdmin\AnypointStudio\workspace\mule-project-test\src\main\resources\wsdl-test\Request.wsdl (The system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at java.io.FileInputStream.<init>(FileInputStream.java:101)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    ... 60 more

The path that the error said is where I had the project before the export.

How can I add the file into the project to avoid that error?. I think that I need to use classpath or something like that but I don't know hot it works.

Added:

This is my actual wsdlLocation:

wsdlLocation = "file:/C:/Users/tstSrvr/AnypointStudio/workspace/test-project/src/main/resources/wsdl-test/Request.wsdl"

Solution

  • It seems you have hardcoded this path C:\Users\usrAdmin\AnypointStudio\workspace\mule-project-test\src\main\resources\wsdl-test\Request.wsdl in your configuration.

    Use wsdl-test/Request.wsdl instead so that way the file can be found both in Studio and when the application is packaged, as it will be loaded from the classpath (as a resource) instead of being loaded as file (via an absolute path).