Results 1 to 5 of 5

Thread: Is it possible to turn off XML Schema Validation on webapp startup?

  1. #1
    Join Date
    Aug 2004
    Location
    Denver
    Posts
    249

    Default Is it possible to turn off XML Schema Validation on webapp startup?

    I'm looking to optimize the time it takes to load up my web application that depends on Spring. One of the suggestions I've heard is to turn off XML Schema validation. Is this easy to do? If so, how? I received the following suggestion from Dan Diephouse, but I'm not directly interacting with the ClassPathXmlApplicationContext - I'm using the ContextLoaderListener and AbstractTransactionalDataSourceSpringContextTests.

    Code:
        @Override
        protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
            super.initBeanDefinitionReader(reader);    
            reader.setValidationModeName(XmlBeanDefinitionReader.VALIDATION_NONE);
        }

  2. #2
    Join Date
    Jul 2005
    Location
    Idaho
    Posts
    231

    Default

    Matt,

    I think one way you can speed up the loading of your application is to set
    <beans xmlns=...
    default-lazy-init="true">
    ...
    </beans>
    in your beans definition.

    This is not very helpful during development though - you won't know if there are bean definition errors at startup.

    Hope that helps,

    Steve O

  3. #3
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    The default ApplicationContext implementation used for web applications and by ContextLoader is the XmlWebApplicationContext, but you can change this by setting contextClass context parameter in web.xml. With this change you can sub-class XmlWebApplicationContext and overwrite appropriate methods to apply your changes. I don't know if there is a more direct way to switch off validation.

    Joerg
    This post can contain insufficient information.

  4. #4
    Join Date
    Feb 2005
    Posts
    9

    Default

    It'd be nice if Spring looked for a system property here instead of forcing people to subclass things...

  5. #5
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by dandiep View Post
    It'd be nice if Spring looked for a system property here ...
    The fact that I'm not aware of one does not mean it does not exist. My approach was only one that should work. You can also raise an enhancement request at Spring's issue tracker.

    Joerg
    This post can contain insufficient information.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •