Announcement Announcement Module
Collapse
No announcement yet.
Spring 3.0.3: Unable to locate Spring NamespaceHandler for XML schema namespace Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3.0.3: Unable to locate Spring NamespaceHandler for XML schema namespace

    Hi,

    Looking for some advice / help from someone I'm looking to upgrade the spring version of one of our applications from 2.5.6 -> 3.0.3 (spring version number utilised by my colleages in a module I need to add to the application)

    The project is built using Maven.
    When I run up the app locally in STS, it runs fine. When I build the app and run it on one of our linux servers, it bombs out with the error message below. Revert back to spring 2.5.6, and it's fine. I've also tried later versions of spring 3, same error.

    Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
    Offending resource: class path resource [application-context.xml]

    at org.springframework.beans.factory.parsing.FailFast ProblemReporter.error(FailFastProblemReporter.java :68)
    at org.springframework.beans.factory.parsing.ReaderCo ntext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderCo ntext.error(ReaderContext.java:80)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.error(BeanDefinitionParserDelegat e.java:284)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1332)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1325)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:135)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De faultBeanDefinitionDocumentReader.java:93)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:149)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:212)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:126)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:92)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:467)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:397)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
    at com.xyz.application.server.Application.main(Applic ation.java:229)


    Other pieces of perhaps useful info:
    application-context.xml (header of)
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    xmlns="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schem...pring-util.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ng-context.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <context:annotation-config />

    <context:mbean-export />.......


    Also:
    spring-context-3.0.0.RELEASE.jar, I've found contains the following in spring.handlers
    http\://www.springframework.org/schema/context=org.springframework.context.config.Context NamespaceHandler
    http\://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHan dler
    http\://www.springframework.org/schema/lang=org.springframework.scripting.config.LangName spaceHandler
    http\://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNam espaceHandler

    Which implies to me that the namespace handler is there....
    There are also no dependcies to spring 2.5.6 in my POM. Any other dependencies that were themselves dependent upon spring 2.5.6 have it set to <scope>provided</scope>, or it's excluded in my POM.


    Any ideas where I need to start looking for a solution?

  • #2
    So I found a work-around. Not pretty, but it works.

    I'm guessing a bit, but it looks like the first spring.handlers/spring.schemas found in the classpath is used and others discarded/ignored (I'm thinking this is why the 2.5.6 Spring uber Jar worked).

    So, the work-around.
    1. Create a META-INF folder in your resources (same place my application.xml, log4j.properties etc are located)
    2. Within the META-INF folder, create new spring.handlers/spring.schemas by concat the individual Spring 3 spring.handlers/spring.schemas together from each spring 3 Jar you have as a dependency

    If anyone has a more elegant solution, I would very much like to hear it.

    Comment


    • #3
      So, a more elegant solution....

      Remove the INDEX.LIST from the main Jar file. This is created by maven in the maven-jar-plugin

      I disabled this, and the issue is now resolved.

      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
      <archive>
      <!-- <index>true</index> -->
      <manifest>
      <mainClass>${appClass}</mainClass>
      <addClasspath>true</addClasspath>
      </manifest>
      </archive>
      </configuration>
      </plugin>

      Comment

      Working...
      X