Announcement Announcement Module
No announcement yet.
How to disable XSD validation in Spring during server start-up? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to disable XSD validation in Spring during server start-up?


    Spring has various configuration files like ( Security, cache ) each depending on its own schema definition (XSD). All these files are present somewhere in the internet. whenever we start the server, all these config files are validated against this XSD which takes a lot of time start the server. In our case, it is between 5-10 mins.

    All we want to do is to disable these validations in developers machine. I searched the web and found this code.


    import org.springframework.beans.BeansException;
    import org.springframework.beans.factory.xml.XmlBeanDefin itionReader;
    import plicationContext;

    public class CustomClassPathXmlApplicationContext extends ClassPathXmlApplicationContext {
    public CustomClassPathXmlApplicationContext(String s, Class aClass) throws BeansException {
    super(s, aClass);

    public CustomClassPathXmlApplicationContext(String s) throws BeansException {

    public CustomClassPathXmlApplicationContext(String[] s) throws BeansException {

    protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
    beanDefinitionReader.setValidationMode(XmlBeanDefi nitionReader.VALIDATION_NONE);

    This one disables the validation in "initBeanDefinitionReader" method. I made this change and added a bean entry in our config.xml file.

    Now, this bean is initialized and loaded into the classpath. Since, I have not tied this bean to web application context it doesn't pick this up during startup because of this even now validations are happening.

    Can anybody guide us on how to tie this up to the web context? If our approach is totally wrong, please guide us on how to resolve the issue. This has been eating our development time a lot.


  • #2

    Take a look here, if you haven't already:

    I'm guessing something like this in web.xml would tie the custom class to the web context:

    		<param-value>your.custom.CustomClassPathXmlApplicationContext </param-value>