No WebApplicationContext found: no ContextLoaderLi

记录一下自己解决tomcat部署遇得到问题的全过程
首先,在tomcat部署上面部署项目时,报如下错误:
严重: Error listenerStart
2014-7-24 14:25:44 org.apache.catalina.core.StandardContext start
严重: Context [/filemanager] startup failed due to previous errors
查了查说是版本问题,将WEB-INF下的web.xml中的

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
    </listener>

改为:

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderServlet</listener-class>
 </listener>

就可以了,结果部署过程中,系统报如下错误:
2014-7-24 14:15:24 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet fileUpload threw exception
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?

at java.lang.Thread.run(Thread.java:619)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:221)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:207)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:146)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

找了好多办法,最后只有将:

<listener-class>org.springframework.web.context.ContextLoaderServlet</listener-class>

换成:

<servlet>
<servlet-name>SpringContextServlet </servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1 </load-on-startup>

结果,在部署项目是报了如下错误:
严重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory‘ defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap

at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.util.SimpleMRUCache.<init>(SimpleMRUCache.java:55)
at org.hibernate.engine.query.QueryPlanCache.<init>(QueryPlanCache.java:76)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:239)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:800)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:726)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1059)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:363)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
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.ContextLoaderServlet.init(ContextLoaderServlet.java:83)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.LRUMap

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 44 more

在百度上查了好长时间,最后确定是:在commons-collections-2.1.1.jar包中找到了LRUMap.class文件但他没在map文件夹下而是直接放在了collections下。后来换了个包commons-collections-3.1.jar.问题解决。
然后呢,我有突发奇想将WEB-INF/web.xml中的

<servlet-name>SpringContextServlet </servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1 </load-on-startup>

改回了

<listener-class>org.springframework.web.context.ContextLoaderListene</listener-class>

结果还是一切正常,万事大吉。

No WebApplicationContext found: no ContextLoaderLi,布布扣,bubuko.com

时间: 2024-10-26 01:17:53

No WebApplicationContext found: no ContextLoaderLi的相关文章

springMVC加载webApplicationContext源码解析

web.xml的节点listener配置了ContextLoaderListener类,这个类继承了ServeltContextListener,所以这个类是随容器的启动而调用方法contextInitialized public void contextInitialized(ServletContextEvent event) { this.contextLoader = createContextLoader(); if (this.contextLoader == null) { thi

扯谈spring mvc之WebApplicationContext的继承关系

spring mvc里的root/child WebApplicationContext的继承关系 在传统的spring mvc程序里会有两个WebApplicationContext,一个是parent,从applicationContext.xml里加载的,一个是child,从servlet-context.xml里加载的. 两者是继承关系,child WebApplicationContext 可以通过getParent()函数获取到root WebApplicationContext.

WebApplicationContext

在Web应用中,我们会用到WebApplicationContext  用它来保存上下文信息 那么它set到ServletContext的过程是怎么样呢 1)通过WEB.XML中监听类 p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco } span.s1 { color: #009193 } span.s2 { color: #4e9192 } <listener-class>org.springframework.web.

有关webapplicationcontext的初始化

ApplicationContext是Spring的核心,Context我们通常解释为上下文环境,我想用“容器”来表述它更容易理解一些,ApplicationContext则是“应用的容器”了:在Web应用中,我们会用到WebApplicationContext,WebApplicationContext继承自ApplicationContext:WebApplicationContext的初始化方式和BeanFactory.ApplicationContext有所区别,因为WebApplica

Spring学习笔记2——web项目初始化webapplicationcontext

1.新建web项目来加载spring webapplicationcontext是专门为web应用准备,它允许从相对于web根目录的路径中装载配置文件,完成初始化操作.从webapplicationcontext中可以获得servletcontext的引用. 2.webapplicationcontext的初始化 通过配置自启动的servlet或web容器监听器 方式一:配置自启动的servlet <!-- 声明自动启动的servlet --> <servlet> <serv

No WebApplicationContext found: no ContextLoaderListener registered?报错解决

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">   今天跑了下新搭的一个SSI框架.报如下错误:</span> <span style="font-size:18px;">严重: Exception sending context initialized event to listener

tomcat启动停止在 Initializing Spring root WebApplicationContext,就不运行了

启动项目的时候,项目一直运行到 Initializing Spring root WebApplicationContext,就停止不运行了,也不报错,开始真的很苦恼,后来把log日志的模式改为 debugg模式,就可以看到报错的原因, 在网上百度了一些信息,大多看不懂,好多是大数据的错误,后来自己琢磨,发现是zookeeper注册中心没有开启,汗(⊙﹏⊙)b,开启zookeeper,就可以完美运行啦. tomcat启动停止,卡死,大概是连接不上一些服务,比如数据库啊,服务器啊,什么的,

Spring中WebApplicationContext的研究

ApplicationContext是Spring的核 心,Context我们通常解释为上下文环境,我想用“容器”来表述它更容易理解一些,ApplicationContext则是“应用的容器” 了:P,Spring把Bean放在这个容器中,在需要的时候,用getBean方法取出,虽然我没有看过这一部分的源代码,但我想它应该是一个类似 Map的结构.在Web应用中,我们会用到WebApplicationContext,WebApplicationContext继承自 ApplicationCont

上下文——webApplicationContext 与servletContext

1.WebApplicationContext的研究 ApplicationContext是spring的核心,Context通常解释为上下文环境,用"容器"来表述更容易理解一些,ApplicationContext则是"应用的容器了"了. spring把bean放在这个容器中,在需要的时候,用getBean()方法取出,在web应用中,会用到webApplicationContext,继承自ApplicationContext 在web.xml初始化WebAppl