UrK
UrK

Reputation: 2300

Unable to locate NamespaceHandler for namespace ('context')

I am fighting with this issue for a few days now and I am really desperate. Legacy project that I am upgrading from gives me the following error message during Tomcat startup:

Configuration problem: Unable to locate NamespaceHandler for namespace
[http://www.springframework.org/schema/context]

Why cannot it process the context schema?


Some background information:

There are a lot of questions about this issue, most of them due to the fact that corresponding JAR is not in the class path. Not in my case. The application is packaged as war and placed into Tomcat's webapp folder. During startup the war is being unpacked by Tomcat into own folder, where WEB-INF/lib folder contains "spring-context-3.2.1.RELEASE.jar" file.

Log files are attached to to the end of this question. Pay attention that tomcat cries about Setting property 'cacheAllowed' to 'false' did not find a matching property. during startup. It seems like it does not load the org.apache.catalina.core.StandardContext. My context.xml file contains the following:

<Context cacheAllowed="false" crossContext="true" debug="0"
    docBase="${project.build.finalName}.war" path="/lup-web" privileged="true"
    reloadable="true">
</Context>

The offending file (services.xml) starts with the following:

<?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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/context 
           http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="com.mycompany.lup.pages"/>
    <context:component-scan base-package="com.mycompany.lup.messages"/>
    <context:component-scan base-package="com.mycompany.lup.importData"/>
    <context:component-scan base-package="com.mycompany.lup.servlet"/>

    <bean class="com.mycompany.lup.importData.ConversionService">

Here is the log of catalina run:

Mar 09, 2013 10:07:56 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.24 using APR version 1.4.6.
Mar 09, 2013 10:07:56 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Mar 09, 2013 10:07:58 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1c 10 May 2012)
Mar 09, 2013 10:07:58 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Mar 09, 2013 10:07:58 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Mar 09, 2013 10:07:58 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1963 ms
Mar 09, 2013 10:07:58 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 09, 2013 10:07:58 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35
Mar 09, 2013 10:07:58 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive C:\Program Files\apache-tomcat-7.0.35\webapps\lup.war
Mar 09, 2013 10:07:58 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'cacheAllowed' to 'false' did not find a matching property.
Mar 09, 2013 10:07:58 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'debug' to '0' did not find a matching property.
Mar 09, 2013 10:08:10 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Mar 09, 2013 10:08:10 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Mar 09, 2013 10:08:13 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 09, 2013 10:08:13 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/lup] startup failed due to previous errors
Mar 09, 2013 10:08:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\apache-tomcat-7.0.35\webapps\docs
Mar 09, 2013 10:08:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\apache-tomcat-7.0.35\webapps\examples
Mar 09, 2013 10:08:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\apache-tomcat-7.0.35\webapps\host-manager
Mar 09, 2013 10:08:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\apache-tomcat-7.0.35\webapps\manager
Mar 09, 2013 10:08:13 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\Program Files\apache-tomcat-7.0.35\webapps\ROOT
Mar 09, 2013 10:08:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Mar 09, 2013 10:08:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Mar 09, 2013 10:08:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 15424 ms

And here is the error log:

Mar 09, 2013 10:08:10 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 09, 2013 10:08:11 PM org.apache.catalina.core.ApplicationContext log
INFO: Loading Spring root WebApplicationContext
Mar 09, 2013 10:08:12 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.mycompany.lup.servlet.DelegatingContextListener
com.mycompany.lup.exceptions.mycompanySystemException: Machine name:DEVTEAM

Error invoking SpringContextLoaderListener upon context initialization.
    at com.mycompany.lup.servlet.DelegatingContextListener.contextInitialized(DelegatingContextListener.java:40)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [conf/services.xml]
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:57)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:64)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:55)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1144)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1137)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:145)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:89)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:499)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:407)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:357)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:187)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:156)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:89)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:499)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:407)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:357)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:123)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:91)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:94)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:294)
    at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    at org.jboss.resteasy.plugins.spring.SpringContextLoaderListener.contextInitialized(SpringContextLoaderListener.java:44)
    at com.mycompany.lup.servlet.DelegatingContextListener.contextInitialized(DelegatingContextListener.java:37)
    ... 14 more

Mar 09, 2013 10:08:13 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Mar 09, 2013 10:08:13 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 09, 2013 10:08:13 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 09, 2013 10:08:13 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@1cb2794d')

Upvotes: 1

Views: 4511

Answers (1)

UrK
UrK

Reputation: 2300

Long story short... It was another issue with invalid dependency. Spring 2.0 jar was somewhere on the CLASSPATH.

Upvotes: 4

Related Questions