Announcement Announcement Module
Collapse
No announcement yet.
Help with an error on validating using XSD Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with an error on validating using XSD

    I'm writting a unit test that extends AbstractTransactionalDataSourceSpringContextTests and am getting
    an error during the parse of my applicationContext.xml file.

    The exception is copied below. I'm having trouble understanding what I need to do to fix my problem. I am running Java 1.4 but I don't know what
    parser I'm using. Upgrading to Java 1.5 isn't an option.

    I've been wondering if I can disable the validation but haven't found a way to do that. I'm using spring 2.1-m2. My xml file starts with:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">



    Thanks for any help you can give.
    Kevin.



    Caused by: javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl @121177e] does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.createDocumentBuilderFactory(DefaultDocu mentLoader.java:105)
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.loadDocument(DefaultDocumentLoader.java: 72)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:351)
    ... 24 more

  • #2
    I've learned one thing about my post. The parser/provider is printed right in the exception and is org.apache.crimson. I'd have a hard time adding libraries to this project so I'm still looking at disabling the validation.

    Comment


    • #3
      Don't think about disabling validation at all. Try to use a more recent version of a parser like Xerces than the default one that comes with the JDK. Therefore you can make use of the so-called endorsed lib directory. There is no need to switch to Java 1.5.

      Joerg

      Comment


      • #4
        Your's is the prefered solution but
        I've already been slapped on the wrist for upgrading or changing libraries
        on this project so I don't feel like doing it again. I ended up disabling the
        validation - not great but it allows me to continue with the unit testing.

        For the record, I overloaded createApplicationContext(String[] locations)
        in my test class and set the validation mode there. Here is the code:

        Code:
            protected ConfigurableApplicationContext createApplicationContext(String[] locations) {
                GenericApplicationContext context = new GenericApplicationContext();
                customizeBeanFactory(context.getDefaultListableBeanFactory());
                XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(context);
                xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
                xmlReader.loadBeanDefinitions(locations);
                context.refresh();
                return context;
            }

        Comment

        Working...
        X