Announcement Announcement Module
Collapse
No announcement yet.
spring and tomcat's class loader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring and tomcat's class loader

    Hi,
    I have a very simple web-application deployed in apache-tomcat-6.0.14. The application uses "spring-2.0.6.jar" located in its WEB-INF/lib, and it works well. For some particular reasons, I have to put "spring-beans-2.5.5.jar" in $TOMCAT_HOME/lib directory, then I have the following exception:

    SEVERE: Context initialization failed
    org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/springmvc-servlet.xml]; nested exception is java.lang.IllegalArgumentException: Class [org.springframework.context.config.ContextNamespac eHandler] does not implement the NamespaceHandler interface
    Caused by: java.lang.IllegalArgumentException: Class [org.springframework.context.config.ContextNamespac eHandler] does not implement the NamespaceHandler interface

    According to Tomcat's document, the "web-app class loader" will try to load classes before it delegates to "common class loader". It means classes in "spring-2.0.6.jar" will be loaded, and since the application runs normally before adding "spring-beans-2.5.5.jar" to $TOMCAT_HOME/lib, no class in "spring-beans-2.5.5.jar" should be loaded.

    So, what is the problem? Does the problem relate to "spring-beans-2.5.5.jar/META-INF/spring.handlers" file? I 'm really clueless. All suggestions are appreciated. Thanks in advance.

    springmvc-servlet.xml:
    <?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">
    <bean name="/hello_world.html" class="springmvc.web.HelloWorldController"/>
    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew"/>
    <property name="prefix" value="/jsp/"/>
    <property name="suffix" value=".jsp"/>
    </bean>
    </beans>

    Exception detail:
    SEVERE: Context initialization failed
    org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/springmvc-servlet.xml]; nested exception is java.lang.IllegalArgumentException: Class [org.springframework.context.config.ContextNamespac eHandler] does not implement the NamespaceHandler interface
    Caused by: java.lang.IllegalArgumentException: Class [org.springframework.context.config.ContextNamespac eHandler] does not implement the NamespaceHandler interface
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.initHandlerMappings(DefaultNam espaceHandlerResolver.java:119)
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.<init>(DefaultNamespaceHandler Resolver.java:96)
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.<init>(DefaultNamespaceHandler Resolver.java:82)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.createDefaultNamespaceHandlerResolver( XmlBeanDefinitionReader.java:488)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.createReaderContext(XmlBeanDefinitionR eader.java:477)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:458)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:353)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:303)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:280)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:131)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:147)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:124)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:92)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:101)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:389)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:324)
    at org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 31)
    at org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:265 )
    at org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:235)
    at org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:126)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1161)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:981)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4045)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4351)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirec tory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:413)

  • #2
    I strongly suggest you to not mix different spring versions it will lead you to more trouble then it gives you an advantages. I suggest upgrade the 2.0.6 version to 2.5.5 that should be a simple matter of switching versions.

    Comment


    • #3
      Thanks for replying. I know that I should not mix different spring versions, and putting "spring-beans-2.5.5.jar" in $TOMCAT_HOME/lib directory maybe not a good idea (web-application portability). However, that is what I got, not what I develop, so the versions of all libraries are not under my control.

      Comment

      Working...
      X