Bean context must contain at least one bean of type org.acegisecurity.util.FilterChainProxy
在使用使用Acegi实现多种用户登录时,出现如下问题:
自己明明实现了该代理,可就是启动出错。
信息: Initializing Spring root WebApplicationContext
2009-03-29 10:10:37,894 INFO [org.springframework.web.context.ContextLoader] - <Root WebApplicationContext: initialization started>
2009-03-29 10:10:38,095 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - <Refreshing org.springframework.web.context.support.XmlWebApplicationContext@55d93d: display name [Root WebApplicationContext]; startup date [Sun Mar 29 10:10:38 CST 2009]; root of context hierarchy>
2009-03-29 10:10:38,365 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - <Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@55d93d]: org.springframework.beans.factory.support.DefaultListableBeanFactory@4ee70b>
2009-03-29 10:10:38,485 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4ee70b: defining beans []; root of factory hierarchy>
2009-03-29 10:10:38,485 INFO [org.springframework.web.context.ContextLoader] - <Root WebApplicationContext: initialization completed in 591 ms>
2009-3-29 10:10:38 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter acegiFilterChain
javax.servlet.ServletException: Bean context must contain at least one bean of type org.acegisecurity.util.FilterChainProxy
at org.acegisecurity.util.FilterToBeanProxy.doInit(FilterToBeanProxy.java:145)
at org.acegisecurity.util.FilterToBeanProxy.init(FilterToBeanProxy.java:189)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
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:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-3-29 10:10:38 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2009-3-29 10:10:38 org.apache.catalina.core.StandardContext start
严重: Context [/Hotel] startup failed due to previous errors
2009-3-29 10:10:38 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
问题找了很久,最后终于定位到了web.xml下,
<!--Spring ApplicationContext file path, separeted by comma.
this parameter usring by Spring-Context loader-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/hotel-*.xml</param-value>
</context-param>
原来是spring的xml配置没读取到,改成如下就可以了:
<!--Spring ApplicationContext file path, separeted by comma.
this parameter usring by Spring-Context loader-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/hotel-*.xml,classpath*:hotel-*.xml</param-value>
</context-param>