Announcement Announcement Module
Collapse
No announcement yet.
Tomcat unable to find FilterChainProxy Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tomcat unable to find FilterChainProxy

    I'm trying to integrate Acegi with my Spring MVC application that uses Hibernate. The beans defined in acegi security are instantiated and can be seen in the log with the message where it is able to find all the security related filters.

    Code:
    INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1d0d45b: defining beans [filterChainProxy,httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor,rememberMeServices,authenticationManager,daoAuthenticationProvider,userDetailsService,loggerListener,daoTarget,messageSource,approval,methodNameResolver,FS,logonValidator,logonForm,org.springframework.aop.config.internalAutoProxyCreator,webRequest,org.springframework.aop.aspectj.AspectJPointcutAdvisor,dummy,urlMapping,viewResolver,dao,theLogger,loggingInterceptor,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer,myDataSource,mySessionFactory]; root of factory hierarchy]
    but it seems Tomcat is not able to resolve the FilterChainProxy and throws this error
    Code:
    SEVERE: Exception starting filter Acegi Filter Chain Proxy
    javax.servlet.ServletException: Bean context must contain at least one bean of type org.acegisecurity.util.FilterChainProxy
    	at org.acegisecurity.util.FilterToBeanProxy.doInit(FilterToBeanProxy.java:145)
    	at org.acegisecurity.util.FilterToBeanProxy.init(FilterToBeanProxy.java:189)
    	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
    	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
    	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
    	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
    Aug 4, 2008 11:54:49 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error filterStart
    my web.xml and acegi security xml has the following entries

    web.xml
    Code:
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			WEB-INF/dispatcher-servlet.xml,WEB-INF/acegi-security.xml,WEB-INF/dao.xml
    		</param-value>
    	</context-param>
    
    	<filter>
    		<filter-name>Acegi Filter Chain Proxy</filter-name>
    		<filter-class>
    			org.acegisecurity.util.FilterToBeanProxy
    		</filter-class>
    		<init-param>
    			<param-name>targetClass</param-name>
    			<param-value>
    				org.acegisecurity.util.FilterChainProxy
    			</param-value>
    		</init-param>
    	</filter>
    
    	<filter-mapping>
    		<filter-name>Acegi Filter Chain Proxy</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    	<listener>
    		<listener-class>
    			org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    
    	<servlet>
    		<servlet-name>dispatcher</servlet-name>
    		<servlet-class>
    			org.springframework.web.servlet.DispatcherServlet
    		</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>dispatcher</servlet-name>
    		<url-pattern>*.htm</url-pattern>
    	</servlet-mapping>
    acegi-security
    Code:
    <bean id="filterChainProxy"
    		class="org.acegisecurity.util.FilterChainProxy">
    		<property name="filterInvocationDefinitionSource">
    			<value><![CDATA[
    				CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    				PATTERN_TYPE_APACHE_ANT
    				/**=httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor
    			]]></value>
    		</property>
    	</bean>
    
    	<bean id="httpSessionContextIntegrationFilter"
    		class="org.acegisecurity.context.HttpSessionContextIntegrationFilter" />
    
    	<bean id="logoutFilter"
    		class="org.acegisecurity.ui.logout.LogoutFilter">
    		<constructor-arg value="/index.jsp" />
    		<!-- URL redirected to after logout -->
    		<constructor-arg>
    			<list>
    				<ref bean="rememberMeServices" />
    				<bean
    					class="org.acegisecurity.ui.logout.SecurityContextLogoutHandler" />
    			</list>
    		</constructor-arg>
    	</bean>
    	
    	<bean id="authenticationProcessingFilter"
    		class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
    		<property name="authenticationManager"
    			ref="authenticationManager" />
    		<property name="authenticationFailureUrl"
    			value="/index.jsp?login_error=1" />
    		<property name="defaultTargetUrl" value="/" />
    		<property name="filterProcessesUrl"
    			value="/j_acegi_security_check" />
    	</bean>
    
    	<bean id="securityContextHolderAwareRequestFilter"
    		class="org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter" />
    
    	<bean id="rememberMeProcessingFilter"
    		class="org.acegisecurity.ui.rememberme.RememberMeProcessingFilter">
    		<property name="authenticationManager"
    			ref="authenticationManager" />
    		<property name="rememberMeServices" ref="rememberMeServices" />
    	</bean>
    
    	<bean id="exceptionTranslationFilter"
    		class="org.acegisecurity.ui.ExceptionTranslationFilter">
    		<property name="authenticationEntryPoint">
    			<bean
    				class="org.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
    				<property name="loginFormUrl" value="/index.jsp" />
    				<property name="forceHttps" value="false" />
    			</bean>
    		</property>
    		<property name="accessDeniedHandler">
    			<bean
    				class="org.acegisecurity.ui.AccessDeniedHandlerImpl">
    				<property name="errorPage" value="/accessDenied.jsp" />
    			</bean>
    		</property>
    	</bean>
    
    	<bean id="filterInvocationInterceptor"
    		class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
    		<property name="authenticationManager"
    			ref="authenticationManager" />
    		<property name="accessDecisionManager">
    			<bean class="org.acegisecurity.vote.AffirmativeBased">
    				<property name="allowIfAllAbstainDecisions"
    					value="false" />
    				<property name="decisionVoters">
    					<list>
    						<bean class="org.acegisecurity.vote.RoleVoter" />
    						<bean
    							class="org.acegisecurity.vote.AuthenticatedVoter" />
    					</list>
    				</property>
    			</bean>
    		</property>
    		<property name="objectDefinitionSource">
    			<value><![CDATA[
    				CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    				PATTERN_TYPE_APACHE_ANT
    				/secure/extreme/**=ROLE_SUPERVISOR
    				/secure/**=IS_AUTHENTICATED_REMEMBERED
    				/**=IS_AUTHENTICATED_ANONYMOUSLY
    			]]></value>
    		</property>
    	</bean>
    
    	<bean id="rememberMeServices"
    		class="org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices">
    		<property name="userDetailsService" ref="userDetailsService" />
    		<property name="key" value="key123" />
    	</bean>
    
    	<bean id="authenticationManager"
    		class="org.acegisecurity.providers.ProviderManager">
    		<property name="providers">
    			<list>
    				<ref local="daoAuthenticationProvider" />
    			</list>
    		</property>
    	</bean>
    
    	<bean id="daoAuthenticationProvider"
    		class="org.acegisecurity.providers.dao.DaoAuthenticationProvider">
    		<property name="userDetailsService" ref="userDetailsService" />
    	</bean>
    
    	<bean id="userDetailsService"
    		class="org.acegisecurity.userdetails.jdbc.JdbcDaoImpl">
    		<property name="dataSource" ref="myDataSource"></property>
    	</bean>
    It seems there is some problem with the Tomcat config. I'm using 5.5.23 version. There is a similar problem encountered in one of the very old posts but there is no solution mentioned. One of the google searches asks to check multiple acegi jars on the class path and i've made sure that there is only 1.

    can somebody provide me a solution or what am i doing wrong?

    Thanks in advance.

  • #2
    Hey!

    I know it sounds a bit stupid but I had a similar problem and I solved it by putting spring-security-core-2.0.3.jar in the /WEB-INF/lib folder.

    And by the way, when using FilterChainProxy the bean in the applicationContext must have the same name as the filter in web.xml, in your case
    <bean id ="Acegi Filter Chain Proxy"....>
    </bean>

    Hope you find a solution!

    Comment

    Working...
    X