1

I'm using eclipse and when I try to run my spring-GWT application in development mode I get the following Exception when parsing the applicationContext.xml file:

    Ignored XML validation warning
    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
(...)
Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 51 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

And my applicationContext.xml file starts like this:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

(...) Line 51 ---> <tx:annotation-driven transaction-manager="transactionManager"/>

Does anyone know what's happening??

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
Neets
  • 4,094
  • 10
  • 34
  • 46

2 Answers2

1

Check you have spring-tx dependencies (or any other spring dependency) in your class path for it to use your schema. All schemas referenced should map to a spring dependency.

xmlns:tx="http://www.springframework.org/schema/tx"

Check this:

http://www.dashaun.com/2010/03/10/springframework-applicationcontext-woes-unable-to-locate-spring-namespacehandler/

code-gijoe
  • 6,949
  • 14
  • 67
  • 103
  • You know, I had a problem like this one a few weeks ago with this from Spring. What I ended up doing is starting over the POM :( I think there is a problem with your POM (I had one). Maybe your maven-war-plugin exports all the .jar correctly but your gwt plugin does not. Check where your pointing your war dir and build dir to see if they get spring-tx. Hope you find your way! – code-gijoe Mar 30 '11 at 14:55
  • can you tell me exactly where and what I have to check? because I thought that in order to run it in development mode there was no need to create a war. (that, or I don't see anywhere!) thanks for your help and sorry for my newbie questions! – Neets Mar 30 '11 at 15:21
0

Found workaround:

When running GWT devmode, there is an issue starting the spring appcontext, the tx...xsd cannot be found. This is related to the classloader defined in this Devmode class of GWT, which delegates to the systemclassloader (override of jetty) see: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/ac495ee6605d21b4

This occurs only when defining the tag in spring which is needed for processing @Transactional annotations for transactions. The only way to solve it I found (after 2 days) is to look in the stacktrace and find which class of Spring invoked xerces (since it is xerces which can't find the file). This was "DefaultDocumentLoader" This class is in spring-beans.jar. => So what I did is, I copied all classes from spring-tx.jar into the new spring-beans.jar so those classes will be loaded by the same classloader Then I also merged the META-INF/spring.handlers, spring.schemas, spring.tooling files, All is now in a new jar i've created: spring-beans-tx-3.0.5.RELEASE.jar This new jar is the first in the classpath of my project. In this case it works !!