30/06/2010

Upgrading to Spring 3: "Unable to locate Spring NamespaceHandler" in JAR file built by Maven

After upgrading to Spring 3 your may discover that your application packaged in JAR archive does not start any more throwing an exception like this:

"Unable to locate Spring NamespaceHandler for XML schema namespace[http://www.springframework.org/schema/tx]"

This happens when you include multiple Spring module dependencies in your pom.xml file and use Maven Shade or Assembly plugin to build a single JAR.
Since Spring can does not contain a single distribution jar (org.springframework:spring:jar), Spring namespace handlers, schema mappings and tooling information files are now present in multiple files with names:

  • META-INF/spring.handlers
  • META-INF/spring.schemas
  • META-INF/spring.tooling

In order to make it work in a single shaded JAR you need to merge contents of these files from different jars and place merged files into new JAR. More...

3 comments:

  1. Look here (including the second comment):

    http://code.google.com/p/google-web-toolkit/issues/detail?id=5728

    for the spring tx workaround

    ReplyDelete
  2. Worked like a charm. Thanks for posting this solution!

    ReplyDelete
  3. Thanks, its working for me as well.

    ReplyDelete

redirect