SpringFramework 3.x applicationContext.xml woes Unable to locate Spring NamespaceHandler

Spring applicationContext.xml struck again today.

Here is the offending code symptom:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]
Offending resource: class path resource [applicationContext.xml]

There seems to be several threads about what causes this error.  My group is doing its first project using the latest and greatest 3.x Spring packages.  Our applicationContext.xml file had xsd and namespace references for several of the spring packages.  Below is the top of our applicationContext.xml file:
< beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" 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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd" >

I’m still not very familiar with the SpringFramework as a whole, but this was actually just an XML problem.  I noticed that the error was failing on the tx xsd.  The spring-tx xsd just happened to be the last xsd reference.  So I moved it just to make sure that the error wasn’t misleading me.  When I moved the reference, it still failed on the spring-tx xsd.  With that information, I knew is was related to the spring-tx xsd.  From there I realized we were just missing the spring-tx dependency in our project.

org.springframework:spring-tx

So if you run into something like the error above make sure that all xsd/namespace that are referenced in your applicationContext.xml are included as dependencies in your pom.xml.

13 thoughts on “SpringFramework 3.x applicationContext.xml woes Unable to locate Spring NamespaceHandler

  1. Pingback: Spring 3 und “Unable to locate Spring NamespaceHandler” Fehler « Tobi’s Blog

  2. Added dependency in the pom.xml as given below
    org.springframework
    spring-tx
    2.5.4

    Still I am getting the error as
    Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]
    Offending resource: class path resource [datasource.xml]

  3. Search for spring-tx-3.0.5.RELEASE.jar file and add it to your project and you’re good!

  4. I’m having this same problem in a project but with the following caveat.

    When running the resulting app in eclipse I have no problems. The project builds a jar with dependencies (importing all the dependency classes via maven into the resulting jar file so it should all be on the classpath). When I run the resulting jar on its own, the error is thrown when the app tries to load its application context.

    Any thoughts?

  5. I’m having the same issue David is. Any thoughts on that?

    Thanks

  6. David and Frederico,
    Have you verified that the application context file is actually included in the resulting jar? Or that it exists on the classpath?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>