1

I'm following this tutorial to secure my GWT application with Spring Security.

However, putting

<!-- Spring Security -->

<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>/app</url-pattern>
</filter-mapping>

<!-- END FILTERS -->

<!-- BEGIN Listeners -->

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

<!-- END Listeners -->

<context-param>
    <param-name>
        contextConfigLocation
    </param-name>
    <param-value>
        classpath:/**/spring-config.xml
    </param-value>
</context-param>

into my web.xml file results in an org.springframework.beans.factory.NoSuchBeanDefinitionException exception. Stack trace:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:660)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1157)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:280)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:962)
    at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:324)
    at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:235)
    at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:199)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    ...

I don't understand why I'm getting this exception - what am I missing?

2 Answers 2

0

DelegatingFilterProxy is a Spring Framework class which delegates to a filter implementation which is defined as a Spring bean in your application context. In this case, the bean is named “springSecurityFilterChain”, which is an internal infrastructure bean created by the namespace to handle web security. Note that you should not use this bean name yourself. Once you've added this to your web.xml, you're ready to start editing your application context file. Web security services are configured using the element.

You should check your spring configuration, dependencies...

Also here is good example of simple Spring security http://www.mkyong.com/spring-security/spring-security-hello-world-example/

0

Have you defined context-param in your web.xml? for e.g,

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
      classpath*:/META-INF/spring/applicationContext-security.xml
      classpath*:/META-INF/spring/applicationContext.xml
      classpath*:/META-INF/spring/applicationContext-gwt-dispatch.xml
    </param-value>
  </context-param>

And in your Spring application context, you have to declare a Spring beans XML file "applicationContext-security.xml" in this case as below,

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:security="http://www.springframework.org/schema/security"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

  <context:property-placeholder location="classpath*:/META-INF/spring/gwtsecurity.properties" />

  <security:user-service id="userService">
    <security:user name="user" password="user" authorities="ROLE_USER" />
    <security:user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
  </security:user-service>

  ...
  <alias name="filterChainProxy" alias="springSecurityFilterChain" />

  <bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy">
    <security:filter-chain-map path-type="ant">
      <security:filter-chain
        filters="securityContextFilter, logoutFilter, formLoginFilter, requestCacheFilter,
            servletApiFilter, rememberMeFilter, anonFilter, sessionMgmtFilter, exceptionTranslator, filterSecurityInterceptor"
        pattern="/**" />
    </security:filter-chain-map>
  </bean>
  <bean
  ...
  </bean>
  ...
</beans>

Ref: https://github.com/dmartinpro/gwt-security/tree/master/gwt-security-sample

3
  • Hi! Hmm.. but where do you actually declare springSecurityFilterChain? Oct 7, 2015 at 17:10
  • It's an alias of filterChainProxy, the answer's been updated. Oct 8, 2015 at 11:31
  • Hi! Sorry for the late answer but I was busy and couldn't continue on this until now. Well, I'm not really getting this. Where does the link you posted declare its FilterChainProxy and where does the example I posted do it? And can't I just change the id filterChainProxy to springSecurityFilterChain? Oct 14, 2015 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.