How to resolve: Spring XSD schema error – schema_reference.4: Failed to read schema document

Problem Statement

While loading a Spring Context XML file i get the following error:
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document …because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not

Solution
This error is caused by the fact that the XSD being referred is not found (either because it does not exist OR there is no internet connection).

1. Download the XSD and place it in your Classpath.
2. In the xsi:schemaLocation=”…” section of your Spring Context file, change the path to XSD from http to classpath.

Originally:
<beans schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&quot;

After Change:
<beans schemalocation="http://www.springframework.org/schema/beans
classpath:spring-beans.xsd

Thats it.

Advertisements

4 responses

  1. This post saved me a whole bunch of time. Thanks v much!

  2. Hey, classpath: is giving the following error
    java.net.MalformedURLException: unknown protocol: classpath

    I have the same problem with respect to persistence.xml. It was all working and I am not sure I have changed something with respect to version now I reverted back but still its throwing the same error.

    I am unable to give the classpath like you have mentioned. Can you help me?

  3. Hi

    It is the version conflict of spring-xxx.jar, the XSD you used is not match with the jar in your class path, for this I change XXD version as the version of jar like

    xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd“>
    to
    xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd“>

    as I have the jar in my classpath spring-2.5.5.jar

    Thank You
    -Bibhuti

  4. Thanks Bibhuti ..possibly version conflict can cause this also.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: