gpt4 book ai didi

java - 无法找到命名空间 ('context' 的 NamespaceHandler)

转载 作者:行者123 更新时间:2023-11-28 22:06:42 26 4
gpt4 key购买 nike

我已经为这个问题奋斗了几天,我真的很绝望。我正在升级的遗留项目在 Tomcat 启动期间给我以下错误消息:

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

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


一些背景信息:

关于这个问题有很多疑问,大部分是因为相应的JAR不在类路径中。不是我的情况。该应用程序打包为 war 并放入 Tomcat 的 webapp 文件夹中。在启动期间,war 被 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">

这是catalina运行的日志:

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.jasper.compiler.TldLocationsCache@1cb2794d')

最佳答案

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

关于java - 无法找到命名空间 ('context' 的 NamespaceHandler),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15315571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com