码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-07-15 10:43:08      阅读:405      评论:0      收藏:0      [点我收藏+]

标签:style   java   color   文件   2014   art   

<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 instance of class com.j.chat.upgrade.web.core.SystemLaunchListener
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
	at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:84)
	at com.j.chat.upgrade.web.core.SystemLaunchListener.contextInitialized(SystemLaunchListener.java:27)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
2014-7-14 19:49:10 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext</span>

    很纳闷,我在web.xml里面已经声明了ContextLoaderListener 这个监听器。我的web.xml配置文件如下:

	<listener>
		<listener-class>com.j.chat.upgrade.web.core.SystemLaunchListener</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>	
  	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring-config.xml</param-value>
	</context-param>
    分析了下,我是在SystemLaunchListener里面执行的时候,发现ContextLoaderListener 这个监听器没有注册。难道是因为这两个listener是先后执行的?调了下这个两个监听器的顺序,把spring的监听器放在了最前面。重启tomcat,就没有这个报错了。

    网上搜了下web.xml文件里listener的执行顺序。下面是一个可信的说法:

    在java web规范中说明.按照listner,filter,servlet的顺序初始化. 
    其中listener是按照在web.xml中的申明顺序执行的.不存在并发的的情况.



No WebApplicationContext found: no ContextLoaderListener registered?报错解决,布布扣,bubuko.com

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

标签:style   java   color   文件   2014   art   

原文地址:http://blog.csdn.net/bruce128/article/details/37768027

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!