Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

java - Getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined

I am running NTLM using Spring Security, I am getting the following error

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined

How can I resolve this error?

I have the following defined in web.xml

<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>

Update 1

I resolved that error, now I am getting

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'filterSecurityInterceptor' is defined

and I have the following

<bean id="springSecurityFilterChain" class="org.acegisecurity.util.FilterChainProxy">
    <property name="filterInvocationDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /**=httpSessionContextIntegrationFilter, exceptionTranslationFilter, ntlmFilter, filterSecurityInterceptor
    </value>
    </property>
    </bean>`

I changed my applicationContext.xml as follows because like @Sean Patrick Floyd mentioned some elements were old and dead and buried. However I have other errors now which needs to be fixed :-)

Thanks

<?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:security="http://www.springframework.org/schema/security"
       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.2.xsd">
  <!--<authentication-manager alias="_authenticationManager"></authentication-manager>-->
  <security:authentication-provider>
    <security:user-service>
      <security:user name="testuser" password="PASSWORD" authorities="ROLE_USER, ROLE_ADMIN"/>
      <security:user name="administrator" password="PASSWORD" authorities="ROLE_USER,ROLE_ADMIN"/>
    </security:user-service>
  </security:authentication-provider>
  <bean id="userDetailsAuthenticationProvider"
        class="com.icesoft.icefaces.security.UserDetailsAuthenticationProvider">
    <security:custom-authentication-provider/>
  </bean>
  <bean id="ntlmEntryPoint"
        class="org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint">
    <property name="authenticationFailureUrl" value="/accessDenied.jspx"/>
  </bean>
  <bean id="ntlmFilter" class="org.springframework.security.ui.ntlm.NtlmProcessingFilter">
    <security:custom-filter position="NTLM_FILTER"/>
    <property name="stripDomain" value="true"/>
    <property name="defaultDomain" value="domain"/>
    <property name="netbiosWINS" value="domain"/>
    <property name="authenticationManager" ref="_authenticationManager"/>
  </bean>
  <bean id="exceptionTranslationFilter"
        class="org.springframework.security.ui.ExceptionTranslationFilter">
    <property name="authenticationEntryPoint" ref="ntlmEntryPoint"/>
  </bean>
  <security:http access-decision-manager-ref="accessDecisionManager"
                 entry-point-ref="ntlmEntryPoint">
    <security:intercept-url pattern="/accessDenied.jspx" filters="none"/>
    <security:intercept-url pattern="/**" access="ROLE_USER"/>
  </security:http>
  <bean id="accessDecisionManager" class="org.springframework.security.vote.UnanimousBased">
    <property name="allowIfAllAbstainDecisions" value="false"/>
    <property name="decisionVoters">
      <list>
        <bean id="roleVoter" class="org.springframework.security.vote.RoleVoter"/>
      </list>
    </property>
  </bean>
</beans>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the DelegatingFilterProxy docs:

Notice that the filter is actually a DelegatingFilterProxy, and not the class that will actually implement the logic of the filter. What DelegatingFilterProxy does is delegate the Filter's methods through to a bean which is obtained from the Spring application context. This enables the bean to benefit from the Spring web application context lifecycle support and configuration flexibility. The bean must implement javax.servlet.Filter and it must have the same name as that in the filter-name element. Read the Javadoc for DelegatingFilterProxy for more information

You need to define a bean named springSecurityFilterChain that implements javax.servlet.Filter in your application context.

From Getting Started with Security Namespace Configuration:

If you are familiar with pre-namespace versions of the framework, you can probably already guess roughly what's going on here. The <http> element is responsible for creating a FilterChainProxy and the filter beans which it uses. Common problems like incorrect filter ordering are no longer an issue as the filter positions are predefined.

So you need at least A Minimal <http> Configuration


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...