Wednesday, March 20, 2013

Spring schemaLocation fails

I used to get this error
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document '/spring-beans-3.1.xsd'…

Basically, it is because wrong version of jar files were in classpath.

Spring handles the schemas by “META-INF/spring.handlers” and “META-INF/spring.schemas”. As long as the correct version spring jar file in classpath, there should not be any problem.

Here is another quick workaround.

As all schema files were packaged in spring jar file. It should be able to find it from the classpath.

The key is the spring-context-3.1.xsd. The setting below works for me and I only set the context xsd from the classpath.


<beans xmlns=""






    xsi:schemaLocation=" classpath:org/springframework/beans/factory/xml/spring-context-3.1.xsd">

Here is an article from internet about this topic.

No comments:

Post a Comment