Type
Exception Report
Message
Servlet.init() for servlet springmvc threw exception
Description
The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
org.apache.coyote.AbstractProtocol A b s t r a c t C o n n e c t i o n H a n d l e r . p r o c e s s ( A b s t r a c t P r o t o c o l . j a v a : 684 ) o r g . a p a c h e . t o m c a t . u t i l . n e t . A p r E n d p o i n t AbstractConnectionHandler.process(AbstractProtocol.java:684) org.apache.tomcat.util.net.AprEndpoint AbstractConnectionHandler.process(AbstractProtocol.java:684)org.apache.tomcat.util.net.AprEndpointSocketProcessor.doRun(AprEndpoint.java:2527)
org.apache.tomcat.util.net.AprEndpoint S o c k e t P r o c e s s o r . r u n ( A p r E n d p o i n t . j a v a : 2516 ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( U n k n o w n S o u r c e ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r SocketProcessor.run(AprEndpoint.java:2516) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor SocketProcessor.run(AprEndpoint.java:2516)java.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)java.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
Root Cause
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [springmvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 78; cvc-elt.1: 找不到元素 ‘beans’ 的声明。
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:591)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:511)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:452)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
org.apache.coyote.AbstractProtocol A b s t r a c t C o n n e c t i o n H a n d l e r . p r o c e s s ( A b s t r a c t P r o t o c o l . j a v a : 684 ) o r g . a p a c h e . t o m c a t . u t i l . n e t . A p r E n d p o i n t AbstractConnectionHandler.process(AbstractProtocol.java:684) org.apache.tomcat.util.net.AprEndpoint AbstractConnectionHandler.process(AbstractProtocol.java:684)org.apache.tomcat.util.net.AprEndpointSocketProcessor.doRun(AprEndpoint.java:2527)
org.apache.tomcat.util.net.AprEndpoint S o c k e t P r o c e s s o r . r u n ( A p r E n d p o i n t . j a v a : 2516 ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( U n k n o w n S o u r c e ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r SocketProcessor.run(AprEndpoint.java:2516) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor SocketProcessor.run(AprEndpoint.java:2516)java.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)java.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
我的配置是这样的
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
接下来就是改
1、首先改版本号,改为4.0————————无效
2、在最后xsd ">加一个空格————————无效
3、检查命名空间————————没有错
4、去掉一些命名空间,因为我看其他人没有context和mvc这一项的——————无效
我觉得我要放弃了,但是还是想试试,不甘心啊
我看到有人发了一份头文件,所以我拷贝之后替代掉自己的
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
">
对,就是这一份,你可能觉得好像没有什么不一样,但是真的是这一份救了我,我把我的头文件替换成这一份之后居然成功了。所以,请复制这一份试一试。一定要试一试。
成功了之后我就在原来的基础上把格式重新改成我觉得舒服的,然后还加入了context,mvc,结果都没有出错了,但是当我把这一份注释掉,用自己的那一份,无论是改版本还是什么的都出现错误,所以一定要试一试上面这份。我下面现在改成这样,不会出错了
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">