spring - No bean named springSecurityFilterChain is defined -
i need integrate spring security small application built spring 3.1.1, following this tutorial @ point 3.2.1, got error trace:
gen 31, 2014 3:08:41 pm org.apache.catalina.core.standardcontext filterstart grave: exception starting filter springsecurityfilterchain org.springframework.beans.factory.nosuchbeandefinitionexception: no bean named 'springsecurityfilterchain' defined @ org.springframework.beans.factory.support.defaultlistablebeanfactory.getbeandefinition(defaultlistablebeanfactory.java:529) @ org.springframework.beans.factory.support.abstractbeanfactory.getmergedlocalbeandefinition(abstractbeanfactory.java:1095) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:277) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:197) @ org.springframework.context.support.abstractapplicationcontext.getbean(abstractapplicationcontext.java:1097) @ org.springframework.web.filter.delegatingfilterproxy.initdelegate(delegatingfilterproxy.java:326) @ org.springframework.web.filter.delegatingfilterproxy.initfilterbean(delegatingfilterproxy.java:236) @ org.springframework.web.filter.genericfilterbean.init(genericfilterbean.java:194) @ org.apache.catalina.core.applicationfilterconfig.initfilter(applicationfilterconfig.java:281) @ org.apache.catalina.core.applicationfilterconfig.getfilter(applicationfilterconfig.java:262) @ org.apache.catalina.core.applicationfilterconfig.<init>(applicationfilterconfig.java:107) @ org.apache.catalina.core.standardcontext.filterstart(standardcontext.java:4775) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5452) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.core.containerbase.addchildinternal(containerbase.java:901) @ org.apache.catalina.core.containerbase.addchild(containerbase.java:877) @ org.apache.catalina.core.standardhost.addchild(standardhost.java:633) @ org.apache.catalina.startup.hostconfig.deploydescriptor(hostconfig.java:656) @ org.apache.catalina.startup.hostconfig$deploydescriptor.run(hostconfig.java:1635) @ java.util.concurrent.executors$runnableadapter.call(executors.java:471) @ java.util.concurrent.futuretask.run(futuretask.java:262) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:744) gen 31, 2014 3:08:41 pm org.apache.catalina.core.standardcontext startinternal grave: error filterstart gen 31, 2014 3:08:41 pm org.apache.catalina.core.standardcontext startinternal grave: context [/mmasgis] startup failed due previous errors gen 31, 2014 3:08:41 pm org.apache.catalina.core.applicationcontext log informazioni: closing spring root webapplicationcontext info : org.springframework.web.context.support.xmlwebapplicationcontext - closing root webapplicationcontext: startup date [fri jan 31 15:08:40 cet 2014]; root of context hierarchy info : org.springframework.beans.factory.support.defaultlistablebeanfactory - destroying singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@204ed39b: defining beans [datasource]; root of factory hierarchy gen 31, 2014 3:08:41 pm org.apache.catalina.loader.webappclassloader clearreferencesjdbc grave: web application [/mmasgis] registered jdbc driver [com.mysql.jdbc.driver] failed unregister when web application stopped. prevent memory leak, jdbc driver has been forcibly unregistered. gen 31, 2014 3:08:41 pm org.apache.catalina.loader.webappclassloader clearreferencesthreads grave: web application [/mmasgis] appears have started thread named [abandoned connection cleanup thread] has failed stop it. create memory leak. gen 31, 2014 3:08:41 pm org.apache.catalina.startup.hostconfig deploydirectory informazioni: deploying web application directory /home/arpho/programmi/sts/springsource/vfabric-tc-server-developer-2.9.3.release/base-instance/webapps/manager gen 31, 2014 3:08:41 pm org.apache.catalina.startup.hostconfig deploydirectory informazioni: deploying web application directory /home/arpho/programmi/sts/springsource/vfabric-tc-server-developer-2.9.3.release/base-instance/webapps/root gen 31, 2014 3:08:41 pm org.apache.coyote.abstractprotocol start informazioni: starting protocolhandler ["http-bio-8080"] gen 31, 2014 3:08:41 pm org.apache.catalina.startup.catalina start informazioni: server startup in 2497 ms
i have referred other threads no solution. can correct me problem in configuration?
thanks time.
this web.xml
:
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" 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"> <!-- definition of root spring container shared servlets , filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml</param-value> </context-param> <!-- creates spring container shared servlets , filters --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- processes application requests --> <servlet> <servlet-name>mmasgisservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mmasgisservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
this root-context.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" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- root context: defines shared resources visible other web components --> <bean id="datasource" name="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="username" value="root"></property> <property name="password" value="password"></property> <property name="driverclassname"> <value>com.mysql.jdbc.driver</value> </property> <property name="url" value="jdbc:mysql://localhost:3306/mmasgis"> </property> </bean> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> </beans> </beans>
make sure security xml loaded contextloaderlistener , not dispatcherservlet. delegatingfilterproxy root applicationcontext (which loaded contextloaderlistener) bean delegate to. (see spring's documentation here)
in case have 1 dispatcher servlet, can define application context globally , leave dispatcher servlet parameter empty.
example:
<!-- definition of root spring container shared servlets , filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml, /web-inf/spring/appservlet/servlet-context.xml</param-value> </context-param> <!-- processes application requests --> <servlet> <servlet-name>mmasgisservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value></param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
Comments
Post a Comment