Tuesday, 15 September 2015

java - Spring 4 Spring Security 3.2.2 No bean named 'springSecurityFilterChain' is defined -



java - Spring 4 Spring Security 3.2.2 No bean named 'springSecurityFilterChain' is defined -

i know has been asked lot, none of answers seem work me. i've been banging head against spring security lastly 2 days , had 0 luck. documentation claims it's super easy setup, can't help sense missing something.

my web.xml:

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>springproject</display-name> <!-- spring configuration files --> <context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath*:mvcdispatcher-servlet.xml classpath*:application-security.xml </param-value> </context-param> <!-- spring security filters --> <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> <!-- spring listeners --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- mvc filter --> <servlet> <servlet-name>mvcdispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>mvcdispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>

and application-security.xml:

<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="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-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <global-method-security secured-annotations="enabled" /> <http use-expressions="true"> <form-login login-page="/login" login-processing-url="/j_spring_security_check" default-target-url="/view" authentication-failure-url="/login?login_error=t" /> <intercept-url pattern="/login" access="isanonymous()" /> <intercept-url pattern="/**" access="isauthenticated()" /> </http> <authentication-manager> <authentication-provider user-service-ref="userservice" /> </authentication-manager> <user-service id="userservice"> <user name="user" password="password" authorities="role_admin" /> </user-service> </beans:beans>

when deploy (to was8.0) , effort login page, error:

com.ibm.ws.webcontainer.webapp.webapp logservleterror srve0293e: [servlet error]-[mvcdispatcher]: org.springframework.beans.factory.nosuchbeandefinitionexception: no bean named 'springsecurityfilterchain' defined

if alter web.xml from:

<context-param> <param-name>contextconfiglocation</param-name> <param-value> classpath*:mvcdispatcher-servlet.xml classpath*:application-security.xml </param-value> </context-param>

to:

<context-param> <param-name>contextconfiglocation</param-name> <param-value> web-inf/mvcdispatcher-servlet.xml web-inf/application-security.xml </param-value> </context-param>

i error

[servlet error]-[mvcdispatcher]: org.springframework.beans.factory.parsing.beandefinitionparsingexception: configuration problem: unable locate spring namespacehandler xml schema namespace [http://www.springframework.org/schema/security]

i have no thought causing or why spring security not working here. it's been incredibly frustrating. assistance appreciated, thanks!

try next in web.xml.

<context-param> <param-name>contextconfiglocation</param-name> <param-value>web-inf/application-security.xml</param-value> </context-param>

note:

the web-inf directory not on classpath. the dispatcherservlet looks web-inf/[servlet-name]-servlet.xml default.

java spring spring-mvc spring-security

No comments:

Post a Comment