0

How can I avoid XSD validation of the application.xml file for Spring when starting up the server?

My company has the access cut to go out to the internet in some servers and the application fails on start up because it can't validate against the XSD in http://www.springframework.org/schema/beans/spring-beans-4.0.xsd for example.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • 1
    Spring doesn't need internet as it ships internally with the XSD. If it fails that basically means you have something wrong/weird in your setup. – M. Deinum Mar 12 '18 at 14:56
  • Only fails in an enviroment where there is no out to the internet, in all other it works.. – Fernando Guardiola Mar 12 '18 at 15:12
  • Have you checked https://stackoverflow.com/questions/1729307/spring-schemalocation-fails-when-there-is-no-internet-connection ? – Olaf Mar 12 '18 at 15:27
  • It shouldn't need internet... Heck been working offline for ages without problems. Hence it must be something in your setup. Spring is shipping with the xsd internally especially to circumvent the need for a live connection. – M. Deinum Mar 13 '18 at 07:49

2 Answers2

1

All you are right too. If version in XSD is the same as the version of the libraries it don't go to internet..

http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

instead of

http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd

It works too!

0

Implementing my own

public class CustomXmlWebApplicationContext extends XmlWebApplicationContext {

        protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) {
            super.initBeanDefinitionReader(beanDefinitionReader);
            beanDefinitionReader.setValidating(false);
            beanDefinitionReader.setNamespaceAware(true);
        }

    }

and in web.xml

 <context-param>
        <param-name>contextClass</param-name>
        <param-value>net.axisdata.cache.web.CustomXmlWebApplicationContext</param-value>
    </context-param>

It works!