我在下面收到以下错误:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 配置问题:无法执行 找到适用于XML的Spring NamespaceHandler 架构命名空间 [http://www.springframework.org/schema/mvc] 违规资源:ServletContext 资源 [/WEB-INF/raceLeague-servlet.xml]
org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281) org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1294) org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126) javax.servlet.GenericServlet.init(GenericServlet.java:160) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:188) org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:288) java.util.concurrent.ThreadPoolExecutor中的$ Worker.runTask(未知 资源) java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(未知 来源)java.lang.Thread.run(未知 源)
我不太清楚为什么但是我猜测我的servlett.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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<context:component-scan base-package="com.jr" />
</beans>
我正在使用的Spring库是http://www.springsource.com/download/community。我看到了两套jar文件。一个在dist文件夹中,一个在src文件夹中。我使用dist文件夹中的jar文件并将其添加到我的WEB-INF / lib文件夹中。
这是我的lib文件夹:
28/02/2005 16:32 999,966 ant-1.6.2.jar
28/02/2005 16:32 5,659 ant-antlr-1.6.2.jar
28/02/2005 16:32 73,665 ant-junit-1.6.2.jar
28/02/2005 16:32 8,673 ant-launcher-1.6.2.jar
28/02/2005 16:32 6,755 ant-swing-1.6.2.jar
18/08/2010 11:36 443,432 antlr-2.7.6.jar
28/02/2005 16:32 1,221 antlr.license.txt
29/11/2009 23:03 345,048 apache-mime4j-0.6.jar
28/02/2005 16:32 11,358 apache.license-2.0.txt
28/02/2005 16:32 2,660 apache.license.txt
28/02/2005 16:32 397,997 c3p0-0.8.5.jar
28/02/2005 16:32 26,430 c3p0.license.txt
13/09/2010 13:54 322,362 cglib-nodep-2.2.jar
28/02/2005 16:32 142,704 cleanimports.jar
30/07/2010 11:51 232,019 commons-beanutils-1.8.3.jar
29/11/2009 23:02 46,725 commons-codec-1.3.jar
28/02/2005 16:32 175,426 commons-collections-2.1.1.jar
18/08/2010 11:36 559,366 commons-collections-3.1.jar
30/07/2010 11:48 575,389 commons-collections-3.2.1.jar
07/02/2010 11:56 707,465 commons-dbcp-1.4-javadoc.jar
07/02/2010 11:55 159,513 commons-dbcp-1.4-sources.jar
07/02/2010 11:52 160,519 commons-dbcp-1.4.jar
23/09/2010 09:10 59,590 commons-fileupload-1.2.2.jar
23/09/2010 09:10 109,043 commons-io-1.4.jar
30/07/2010 11:35 279,193 commons-lang-2.5.jar
28/02/2005 16:32 38,015 commons-logging-1.0.4.jar
01/11/2009 14:58 60,686 commons-logging-1.1.1.jar
30/07/2010 10:27 60,841 commons-logging.jar
12/11/2009 19:43 436,817 commons-pool-1.5.4-javadoc.jar
12/11/2009 19:43 96,194 commons-pool-1.5.4-sources.jar
12/11/2009 19:38 96,221 commons-pool-1.5.4.jar
28/02/2005 16:32 171,071 concurrent-1.3.2.jar
28/02/2005 16:32 17,978 connector.jar
28/02/2005 16:32 9,790 connector.licence.txt
28/02/2005 16:32 312,509 dom4j-1.5.2.jar
18/08/2010 11:36 313,898 dom4j-1.6.1.jar
28/02/2005 16:32 47,531 ehcache-1.1.jar
30/07/2010 11:42 86,487 ezmorph-1.0.6.jar
27/05/2010 16:38 100,884 hibernate-jpa-2.0-api-1.0.0.Final
11/06/2009 17:35 2,220,643 hibernate3.jar
03/12/2009 22:43 291,039 httpclient-4.0.1.jar
29/11/2009 23:05 172,888 httpcore-4.0.1.jar
03/12/2009 22:43 25,443 httpmime-4.0.1.jar
28/02/2005 16:32 104,359 jaas.jar
28/02/2005 16:32 9,863 jaas.licence.txt
28/02/2005 16:32 24,180 jacc-1_0-fr.jar
18/08/2010 11:36 597,476 javassist-3.9.0.GA.jar
28/02/2005 16:32 239,006 jaxen-1.1-beta-4.jar
28/02/2005 16:32 342,872 jboss-cache.jar
28/02/2005 16:32 389,484 jboss-common.jar
28/02/2005 16:32 588,329 jboss-jmx.jar
28/02/2005 16:32 165,248 jboss-remoting.jar
28/02/2005 16:32 215,223 jboss-system.jar
28/02/2005 16:32 6,727 jdbc2_0-stdext.jar
28/02/2005 16:32 7,932 jdbc2_0-stdext.licence.txt
28/02/2005 16:32 1,652,084 jgroups-2.2.7.jar
30/07/2010 09:42 151,390 json-lib-2.3-jdk13.jar
30/07/2010 11:39 151,839 json-lib-2.3-jdk15.jar
30/07/2010 11:58 414,240 jstl-1.2.jar
18/08/2010 11:47 10,899 jta-1.1.jar
28/02/2005 16:32 8,812 jta.jar
28/02/2005 16:32 9,830 jta.licence.txt
28/02/2005 16:32 121,070 junit-3.8.1.jar
28/02/2005 16:32 352,291 log4j-1.2.9.jar
10/09/2010 16:12 236,079 mysql-connector-java-3.0.16-ga-bi
10/09/2010 16:12 391,434 mysql-connector-java-3.1.6-bin.ja
23/06/2010 16:38 767,492 mysql-connector-java-5.1.13-bin.j
20/10/2010 16:21 321,190 org.springframework.aop-3.0.5.REL
20/10/2010 16:21 53,082 org.springframework.asm-3.0.5.REL
20/10/2010 16:21 35,548 org.springframework.aspects-3.0.5
r
20/10/2010 16:21 555,410 org.springframework.beans-3.0.5.R
20/10/2010 16:21 668,861 org.springframework.context-3.0.5
r
20/10/2010 16:21 100,870 org.springframework.context.suppo
LEASE.jar
20/10/2010 16:21 382,442 org.springframework.core-3.0.5.RE
20/10/2010 16:21 169,752 org.springframework.expression-3.
.jar
20/10/2010 16:21 1,810 org.springframework.instrument-3.
.jar
20/10/2010 16:21 5,728 org.springframework.instrument.to
RELEASE.jar
20/10/2010 16:21 385,712 org.springframework.jdbc-3.0.5.RE
20/10/2010 16:21 185,312 org.springframework.jms-3.0.5.REL
20/10/2010 16:21 334,327 org.springframework.orm-3.0.5.REL
20/10/2010 16:21 61,379 org.springframework.oxm-3.0.5.REL
20/10/2010 16:21 205,278 org.springframework.test-3.0.5.RE
20/10/2010 16:21 231,922 org.springframework.transaction-3
E.jar
20/10/2010 16:21 395,587 org.springframework.web-3.0.5.REL
20/10/2010 16:21 175,412 org.springframework.web.portlet-3
E.jar
20/10/2010 16:21 418,977 org.springframework.web.servlet-3
E.jar
20/10/2010 16:21 31,404 org.springframework.web.struts-3.
.jar
28/02/2005 16:32 114,308 oscache-2.1.jar
28/02/2005 16:32 475,943 proxool-0.8.3.jar
28/02/2005 16:30 2,862 README.txt
27/05/2010 11:29 22,338 slf4j-api-1.5.6.jar
18/08/2010 11:26 23,445 slf4j-api-1.5.8.jar
27/05/2010 11:30 9,678 slf4j-log4j12-1.5.6.jar
31/10/2008 17:25 325,942 spring-aop.jar
31/10/2008 17:25 488,282 spring-beans.jar
31/10/2008 17:25 96,880 spring-context-support.jar
31/10/2008 17:25 476,940 spring-context.jar
31/10/2008 17:25 285,491 spring-core.jar
31/10/2008 17:25 335,484 spring-jdbc.jar
31/10/2008 17:25 195,350 spring-jms.jar
31/10/2008 17:25 377,805 spring-orm.jar
31/10/2008 17:25 180,924 spring-test.jar
31/10/2008 17:25 231,173 spring-tx.jar
31/10/2008 17:25 194,577 spring-web.jar
31/10/2008 17:25 149,683 spring-webmvc-portlet.jar
31/10/2008 17:25 36,748 spring-webmvc-struts.jar
31/10/2008 17:25 402,396 spring-webmvc.jar
31/10/2008 17:25 2,949,500 spring.jar
28/02/2005 16:32 30,602 swarmcache-1.0rc2.jar
27/05/2010 11:29 47,433 validation-api-1.0.0.GA.jar
28/02/2005 16:30 4,538 version.properties
28/02/2005 16:32 5,762 versioncheck.jar
28/02/2005 16:32 1,010,806 xerces-2.6.2.jar
28/02/2005 16:32 123,705 xml-apis.jar
这里的web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- index.htm web page -->
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
<!-- Register and setup my servlet xml files here -->
<servlet>
<servlet-name>raceLeague</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>raceLeague</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
这也是我的构建脚本:
<?xml version="1.0"?>
<project name="Online Racing League" basedir="." default="usage">
<property file="build.properties"/>
<property name="src.dir" value="src"/>
<property name="web.dir" value="war"/>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
<property name="name" value="Online Racing League"/>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message="install --> Install application in Tomcat"/>
<echo message="reload --> Reload application in Tomcat"/>
<echo message="start --> Start Tomcat application"/>
<echo message="stop --> Stop Tomcat application"/>
<echo message="list --> List Tomcat applications"/>
<echo message=""/>
</target>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${deploy.path}/${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<!-- End Tomcat tasks -->
</project>
下面的build.properties文件:
# Ant properties for building the springapp
appserver.home=C:/Program Files/Apache Software Foundation/Tomcat 7.0
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/lib/
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=
tomcat.manager.password=
答案 0 :(得分:3)
Spring下载包包含Spring框架,分为多个模块,spring-core,spring-beans等。其中一个是org.springframework.web.servlet-3.0.5.RELEASE.jar。
此jar包含mvc架构的xsd。你能确认它在你的类路径上吗?
编辑:
看起来你的lib目录中有多个Spring副本。你有一些来自Spring 2的罐子。移除任何不以org.springframework开头的弹簧罐.... 例如spring.jar,spring-mvc.jar
当你在它的时候,那里还有许多你不需要的其他罐子。您有common-dbcp,commons-collections,commons-pool,dom4j的多个副本。你有Ant罐子和Junit罐子。如果不清除重复项,可能会在运行时遇到其他错误。