Recent Posts
Archives

PostHeaderIcon Spring: Failed to read schema document

Case

I try to deploy a Mule ESB configuration, using this XML:

[xml]<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/pattern
http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd
">
<pattern:simple-service name="authenticationService"
address="http://localhost:1234/authenticationService"
component-class="lalou.jonathan.esb.components.AuthenticationComponent"
type="direct" />
</mule>[/xml]

I get the following error:

[java]Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document ‘http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd'[/java]

Extended Stacktrace

[java]2011-11-22 16:10:25,375 WARN  xml.XmlBeanDefinitionReader         – Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document ‘http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.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:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)[/java]

Notice that Mule ESB files are similar to classic Spring files. Of course, I first checked the pointed XSD was actually reachable.
Anyway, this error should be raised when your application, for any reason -firewall, proxies, network interruption-, cannot access the remote site where the XSD is hosted.

Fix

  • Copy the XSD to a local folder
  • Create a file spring.schemas
  • Make it available in the classpath in META-INF.
  • Add the following line
  • [java]http\://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd=WEB-INF/classes/mule-pattern.xsd[/java]

    The pattern is: missing resource (beware of escaping colon) = path in classpath of the local XSD

  • Rebuild, pack and run!

2 Responses to “Spring: Failed to read schema document”

  • Hola peeps,

    Love it absolutely! So crystalline. No mumbo jumbo. No non-sense.
    Straight and simple. You guys need a standing ovation for your good work.

    Here i am transforming a json file to csv and writing the same file to the desired target(one for the csv file target location and the same to the database at the sametime)
    Steps: –> Drag and drop a file connector and set the path to where your json file is located(Here it is src/main/resources/input). –> Tranform the json file to csv using tranform message –> Drag and drop object-to-byte array tranformer –> Then place the “ALL” router. This will route your message to all targets –> Then place a file connector and specify the path where the csv file has to be placed.(Here it is src/main/resources/output) –> On the other hand, drag and drop a transform message and tranform the incomimg message to java object –> Drag and drop a database connector and configure it –> Run the project and you can see that the input json file has been transformed to csv file and the values are inserted into the database at the same time.

    THANK YOU!! This saved my butt today, I’m immensely grateful.

    Regards,
    Krishna kumar

  • Abhiram says:

    Hello Jonathan,

    I love all the posts, I really enjoyed.
    I would like more information about this, because it is very nice., Thanks for sharing.

    During my time at Mule Soft, I’ve had a lot of conversations with people from other companies about their specific challenges and one recurring theme is almost always present: the conversation starts out talking about point-to-point integrations. It’s pretty natural when presented with two systems to want to draw a connection. The data here is needed there and, after that, we’re done because a problem was solved.

    THANK YOU!! This saved my butt today, I’m immensely grateful.

    Obrigado,
    Abhiram

Leave a Reply for Abhiram