Results 1 to 6 of 6

Thread: Problem when finding springSecurityFilterChain bean

  1. #1

    Default Problem when finding springSecurityFilterChain bean

    Hi,

    I've been trying to use the preauth sample in my own Tomcat 4 application, but am getting the following error when the server starts up:

    2008-05-09 10:01:08 StandardContext[/macroderivatives]: Exception starting filter springSecurityFilterChain
    org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'springSecurityFilterChain' is defined
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:391)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedLocalBeanDefinition(AbstractB eanFactory.java:999)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:174)
    I have the following in my web.xml:

    Code:
        <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>
    And my Spring security context XML is simply:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <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-2.0.xsd
                            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">
    
        <beans:bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
            <filter-chain-map path-type="ant">
                <filter-chain pattern="/**" filters="sif"/>
            </filter-chain-map>
        </beans:bean>
    
        <beans:bean id="sif"
    		class="org.springframework.security.context.HttpSessionContextIntegrationFilter" />
    
    </beans:beans>
    I've seen a few posts regarding the same error, but no real solutions. Any ideas what's up?

    Thanks

    Nick

  2. #2

    Default

    Bah! Ignore me. I needed to call the FilerChainProxy bean "springSecurityFilterChain" and it works.

    Nick

  3. #3
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    Or you can use the name "filterChainProxy" in your web.xml.

  4. #4

    Default

    I had the same issue and turns out <security:http/> and <security:authentication-provider/> need to be in the primary config that's listed in web.xml via:
    Code:
    <context-param>
    	<param-name>contextConfigLocation</param-name>
    	<param-value>/WEB-INF/classes/hibernateSpringContext.xml</param-value>
    </context-param>
    When i had it in a servlet dispatcher configuration file i got the same exception as mentioned above.
    So don't put it here. It will not work:
    Code:
    <servlet>
    	<servlet-name>myDispatcher</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<load-on-startup>1</load-on-startup>
    </servlet>

  5. #5
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    Yes, this is a common misconception with Spring app contexts - the fact that the *-servlet.xml beans aren't visible from the main context. Often people wonder why security pointcuts defined in the main context aren't applied to beans in their web dispatcher context, which is essentially the same problem.

  6. #6
    Join Date
    May 2009
    Posts
    1

    Default Namespace issue

    This had me stumped too. The springSecurityFilterChain bean is supposed to be created automatically when you use the <security:http... /> configuration. It turned out that the problem was not reading the manual... they make security the default xml namespace so in their examples they omit all the "security:" prefixes. If you leave beans as the default namespace, as shown below, you need to use the "security:" prefix everywhere. Then the springSecurityFilterChain bean is created OK. The context file below works fine for me.


    Context-xml

    <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/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">

    <!-- Configure security -->
    <security:http auto-config="true">
    <security:intercept-url pattern="/**" access="ROLE_USER" />
    </security:http>

    <security:authentication-provider>
    <security:user-service>
    <security:user name="jimi" password="jimi" authorities="ROLE_USER, ROLE_ADMIN" />
    <security:user name="bob" password="bob" authorities="ROLE_USER" />
    </security:user-service>
    </security:authentication-provider>

    </beans>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •