无法找到NamespaceHandler的命名空间('上下文')

问题描述:

我与这个问题打了几天,现在我真的很绝望。那我从升级 遗产项目带给我的Tomcat启动过程中出现以下错误信息:无法找到NamespaceHandler的命名空间('上下文')

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

为什么不能处理上下文模式?


一些背景资料:

有很多关于这个问题,大部分问题都是由于对应JAR不在类路径。不是在我的情况。 该应用程序打包为war并放入Tomcat的webapp文件夹中。在启动过程中,Tomcat将其解压到自己的文件夹中,其中WEB-INF/lib文件夹包含“spring-context-3.2.1.RELEASE.jar”文件。

日志文件附加到此问题的结尾。 请注意,tomcat哭泣将属性'cacheAllowed'设置为'false'没有找到匹配的属性。在启动过程中。它似乎不加载org.apache.catalina.core.StandardContext。 我的context.xml文件包含以下内容:

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

有问题的文件(services.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" 
     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"> 

下面是卡特琳娜运行的日志:

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 

这里是错误日志:

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.[email protected]') 
+0

在共享类加载器(CATALINA_HOME/lib)中是否有与弹簧相关的jar? – 2013-03-09 22:28:38

+0

什么都没有。这是Tomcat 7的全新安装 – UrK 2013-03-10 04:51:08

长话短说......这是无效依赖的另一个问题。 Spring 2.0 jar在CLASSPATH的某处。