views:

144

answers:

2

applicationContext.xml

<bean id="defaultEntryPoint" class="com.spsetia.companyapp.company.services.CustomAuthenticationEntryPoint">
    <property name="securityConfiguration" ref="securityConfiguration" />
    <!-- Default filter chain proxy -->
    <property name="proxy" ref="_filterChainProxy" />
</bean>

inside web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml
    </param-value>
  </context-param>
 <filter>
    <filter-name>redirect</filter-name>
    <filter-class>org.apache.tapestry.RedirectFilter</filter-class>
  </filter>
 <filter-mapping>
    <filter-name>redirect</filter-name>
    <url-pattern>/</url-pattern>
  </filter-mapping>
 <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
 <filter>
  <filter-name>_filterChainProxy</filter-name>
  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
  <filter-name>_filterChainProxy</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
    <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
</listener>
  <servlet>
    <servlet-name>app</servlet-name>
    <servlet-class>
      org.apache.tapestry.ApplicationServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

but i get error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainList': Cannot resolve reference to bean '_exceptionTranslationFilter' while setting bean property 'filters' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_exceptionTranslationFilter': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEntryPoint' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean '_filterChainProxy' while setting bean property 'proxy'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainProxy': Initialization of bean failed; nested exception is java.lang.NullPointerException

what do i miss out?

A: 

It looks like you must be using SpringSecurity 2.0.x or 2.5.x. The class FilterChainProxyPostProcessor doesn't seem to exist in the 3.0.x codebase.

After digging around a bit, I found the code where your exception seems to originat:

public Object postProcessBeforeInitialization(Object bean, String beanName) 
throws BeansException {
    if(!BeanIds.FILTER_CHAIN_PROXY.equals(beanName)) {
        return bean;
    }

    FilterChainProxy filterChainProxy = (FilterChainProxy) bean;
    FilterChainList filterList = 
        (FilterChainList) beanFactory.getBean(BeanIds.FILTER_LIST);

    List filters = new ArrayList(filterList.getFilters());
    Collections.sort(filters, new OrderComparator());

My diagnosis is that the NPE is thrown on the line that creates the ArrayList, and that it is due to filterList.getFilters() returning null. Chasing back, the cause would appear to be that the "_filterChainList" bean has not been correctly initialized.

I don't know how or where it should be initialized ...

Stephen C
A: 
FilterChainList filterList = (FilterChainList) 
    beanFactory.getBean(BeanIds.FILTER_LIST);

List filters = new ArrayList(filterList.getFilters());

These lines are the problem. This means that a bean named _filterChainList (the value of the above constant) must have a set of filters defined for it.

Bozho