Rakesh Goyal Rakesh Goyal - 1 year ago 93
Java Question

Disable Schema Validation in Spring 3

We are using JOSSO framework for single sign on. It is working properly in Spring 2.5.6. It seems strict XML schema validation is introduced in Spring 3, JOSSO XSD's are not updated since long time, hence we get errors during startup of server. Is there any way to disable Schema Validation in Spring 3 (Probably make it work similar to 2.5.6)..

Answer Source

I have not tried it yet, but the GenericXmlApplicationContext has a setValidating(boolean validating) method.

I believe you can use this method to deactivate the validation:

GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load("myResource.xml", "otherResource.xml");


If you use spring in a web application then it is more difficult to set the validation parameter. One way I can think of, based on the fact that the ContextLoader uses an web.xml context parameter "contextClass" to specify the context class (default is: org.springframework.web.context.support.XmlWebApplicationContext).

  • @see: org.springframework.web.context.ContextLoader
  • @see: org.springframework.web.context.ContextLoader#determineContextClass(ServletContext)

Maybe you can create a Subclass of XmlWebApplicationContext with disabled validation and use the "contextClass" parameter to load this class instead of XmlWebApplicationContext.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download