的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>
的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>
但是我收到了这个错误:
org.springframework.beans.factory.BeanCreationException: 使用名称创建bean时出错 '_filterChainList':无法解析 引用bean '_exceptionTranslationFilter'而 用bean设置bean属性'filters' 关键[2];嵌套异常是 org.springframework.beans.factory.BeanCreationException: 使用名称创建bean时出错 '_exceptionTranslationFilter': bean的初始化失败;嵌套 例外是 org.springframework.beans.factory.BeanCreationException: 使用名称创建bean时出错 'defaultEntryPoint'定义于 ServletContext资源 [/WEB-INF/applicationContext.xml的]: 无法解析对bean的引用 设置bean时'_filterChainProxy' 财产'代理';嵌套异常是 org.springframework.beans.factory.BeanCreationException: 使用名称创建bean时出错 '_filterChainProxy':初始化 豆子失败了;嵌套异常是 显示java.lang.NullPointerException
我做错了什么?
答案 0 :(得分:0)
看起来您必须使用SpringSecurity 2.0.x或2.5.x.类FilterChainProxyPostProcessor
似乎不存在于3.0.x代码库中。
在挖掘了一下之后,我发现了你的异常似乎来自的代码:
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());
我的诊断是NPE被抛出到创建ArrayList的行上,并且归因于filterList.getFilters()
返回null
。回过头来看,原因似乎是“_filterChainList”bean没有被正确初始化。
我不知道应该如何或在哪里初始化......
答案 1 :(得分:0)
FilterChainList filterList = (FilterChainList)
beanFactory.getBean(BeanIds.FILTER_LIST);
List filters = new ArrayList(filterList.getFilters());
这些线是问题所在。这意味着名为_filterChainList
的bean(上面常量的值)必须有一组为其定义的过滤器。