为什么80%的码农都做不了架构师?>>>   

异常信息:
在使用SpringSecurity3.0.4时出现如下异常,
2010-12-02 10:23:07.890:INFO:/info_platform:Initializing Spring root WebApplicationContext
Hibernate: select resource0_.id as id12_0_, authority2_.id as id1_1_, resource0_.position as position12_0_, resource0_.resource_type as resource3_12_0_, resource0_.value as value12_0_, authority2_.name as name1_1_, authorityl1_.resource_id as resource1_12_0__, authorityl1_.permission_id as permission2_0__ from resource resource0_ left outer join permission_resource authorityl1_ on resource0_.id=authorityl1_.resource_id left outer join permissions authority2_ on authorityl1_.permission_id=authority2_.id where resource0_.resource_type=? order by resource0_.position ASC, authority2_.id asc
[orm:10:23:13] ERROR [main] ContextLoader.initWebApplicationContext(220) | Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChainProxy': Cannot resolve reference to bean 'filterSecurityInterceptor' while setting bean property 'filterChainMap' with key [/**] with key [9]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterSecurityInterceptor' defined in file [E:\workshop\eclipse_jee\info_platform\target\classes\applicationContext-security.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: An AuthenticationManager is required

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterSecurityInterceptor' defined in file [E:\workshop\eclipse_jee\info_platform\target\classes\applicationContext-security.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: An AuthenticationManager is required

Caused by: java.lang.IllegalArgumentException: An AuthenticationManager is required

2010-12-02 10:23:13.765:WARN::Failed startup of context org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@10f3a9c{/info_platform,E:\workshop\eclipse_jee\info_platform\src\main\webapp}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChainProxy': Cannot resolve reference to bean 'filterSecurityInterceptor' while setting bean property 'filterChainMap' with key [/**] with key [9]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterSecurityInterceptor' defined in file [E:\workshop\eclipse_jee\info_platform\target\classes\applicationContext-security.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: An AuthenticationManager is required

2010-12-02 10:23:13.765:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChainProxy': Cannot resolve reference to bean 'filterSecurityInterceptor' while setting bean property 'filterChainMap' with key [/**] with key [9]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterSecurityInterceptor' defined in file [E:\workshop\eclipse_jee\info_platform\target\classes\applicationContext-security.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: An AuthenticationManager is required:
java.lang.IllegalArgumentException: An AuthenticationManager is required
    at org.springframework.util.Assert.notNull(Assert.java:112)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.afterPropertiesSet(AbstractSecurityInterceptor.java:118)

原因:
看异常信息可知是缺少AuthenticationManager,也就是在创建filterSecurityInterceptor这个bean时缺少AuthenticationManager!

解决办法:
在filterSecurityInterceptor这个过滤器bean的定义处加上缺少的AuthenticationManager即可!
修正前的在SpringSecurity3的配置文件applicationContext-security.xml中的片段如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:s="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/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"default-lazy-init="true"><description>SpringSecurity安全配置</description><!-- http安全配置 --><s:http auto-config="true" use-expressions="true"><!-- 对登录页面不进行拦截,至于后面的*,是因为请求的页面可能包含一些参数! --><s:intercept-url pattern="/login.jsp*" filters="none"/><s:intercept-url pattern="/static/**" filters="none"/><s:intercept-url pattern="/decorators/**" filters="none"/><s:intercept-url pattern="/uploads/**" filters="none"/><s:intercept-url pattern="/common/**" filters="none"/><!-- 配置登录页面!设置always-use-default-target成"true",用户登录后总是会转发到default-target-url指定的位置,无论他们在登录页面之前访问的什么位置。 解决使用局部刷新功能的环境下,用户在Login之后应该自动跳到Login之前访问的安全资源导致的页面只显示局部的问题!--><s:form-login login-page="/login" default-target-url="/index.jsp" authentication-failure-url="/login?error=true" always-use-default-target="true"/><s:logout logout-success-url="/index.jsp"/><!-- 注意:在SS3.0.x中,自定义的filter的配置要放在s:http里 --><s:custom-filter ref="filterSecurityInterceptor" before="FILTER_SECURITY_INTERCEPTOR"/><s:custom-filter ref="reAuthenticationFilter" before="FORM_LOGIN_FILTER"/><!-- TODO 自定义的未授权访问拒绝的处理器 --><s:access-denied-handler ref="accessDeniedHandler"/></s:http><!--<s:http auto-config="true" access-decision-manager-ref="accessDecisionManager"><s:form-login login-page="/logreg.action" default-target-url="/"authentication-failure-url="/logreg.action?error=true" /><s:logout logout-success-url="/" /><s:remember-me key="e37f4b31-0c45-11dd-bd0b-0800200c9a66" /></s:http>--><bean id="reAuthenticationFilter" class="com.leeoo.common.web.access.filter.ReAuthenticationFilter"><property name="userDetailsService" ref="userDetailsService" /></bean><bean id="accessDeniedHandler" class="com.leeoo.common.security.AccessDenied4AjaxHandlerImpl"><property name="accessDeniedUrl" value="/common/403.jsp"/></bean><!-- 认证配置,使用userDetailsService提供的用户信息 --><s:authentication-manager alias="authenticationManager"><s:authentication-provider user-service-ref="userDetailsService"><!-- 可设置hash使用sha1或md5散列密码后再存入数据库,默认是不加密的纯文本明文,默认的加密方式请参考BasePasswordEncoder类--><s:password-encoder hash="md5"><!-- 将每个用户的username作为盐值(加密种子) --><s:salt-source user-property="username"/></s:password-encoder></s:authentication-provider></s:authentication-manager><!-- 项目实现的用户查询服务 --><bean id="userDetailsService" class="com.leeoo.info_platform.account.service.UserDetailsServiceImpl" /><!--JCaptcha验证码服务<bean id="captchaService" class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService"><property name="captchaEngine"><bean class="com.zenithen.skynet.skynet.security.jcaptcha.GMailEngine" /></property>默认生成的图片180秒过期 , 可另行设置<property name="minGuarantedStorageDelayInSeconds" value="180" /></bean> --><!-- 重新定义的FilterSecurityInterceptor,使用databaseDefinitionSource提供的url-授权关系定义 --><!-- <bean id="filterSecurityInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor"> SpringSecurity2.0.x中使用 --><bean id="filterSecurityInterceptor" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor"><!--<s:custom-filter before="FILTER_SECURITY_INTERCEPTOR" /><s:custom-filter ref="databaseDefinitionSource" before="FILTER_SECURITY_INTERCEPTOR"/>--><property name="accessDecisionManager" ref="accessDecisionManager" /><property name="securityMetadataSource" ref="databaseDefinitionSource" /><!-- <property name="objectDefinitionSource" ref="databaseDefinitionSource" /> 注:objectDefinitionSource在SS3中已经标记为过时了,要换用securityMetadataSource --></bean><!-- DefinitionSource工厂,使用resourceDetailsService提供的URL-授权关系. --><!--<bean id="databaseDefinitionSource" class="com.leeoo.info_platform.service.account.DefinitionSourceFactoryBean"><property name="resourceDetailsService" ref="resourceDetailsService" /></bean>--><bean id="databaseDefinitionSource" class="com.leeoo.info_platform.common.web.access.intercept.MyFilterInvocationSecurityMetadataSource"><constructor-arg index="0"><bean class="org.springframework.security.web.util.AntUrlPathMatcher"/></constructor-arg><constructor-arg index="1" ref="resourceDetailsService"/></bean><!-- 项目实现的URL-授权查询服务 --><bean id="resourceDetailsService" class="com.leeoo.info_platform.account.service.ResourceDetailsServiceImpl" /><!-- 授权判断配置, 将授权名称的默认前缀由ROLE_改为A_. --><!-- <bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased"> SpringSecurity2.0.x中使用 --><bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"><property name="decisionVoters"><list><!-- <bean class="org.springframework.security.vote.RoleVoter"> SpringSecurity2.0.x中使用 --><bean class="org.springframework.security.access.vote.RoleVoter"><property name="rolePrefix" value="A_"/></bean><!-- <bean class="org.springframework.security.vote.AuthenticatedVoter" /> SpringSecurity2.0.x中使用 --><bean class="org.springframework.security.access.vote.AuthenticatedVoter" /></list></property></bean>
</beans>

修正后的在SpringSecurity3的配置文件applicationContext-security.xml中的片段如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:s="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/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"default-lazy-init="true"><description>SpringSecurity安全配置</description><!-- http安全配置 --><s:http auto-config="true" use-expressions="true"><!-- 对登录页面不进行拦截,至于后面的*,是因为请求的页面可能包含一些参数! --><s:intercept-url pattern="/login.jsp*" filters="none"/><s:intercept-url pattern="/static/**" filters="none"/><s:intercept-url pattern="/decorators/**" filters="none"/><s:intercept-url pattern="/uploads/**" filters="none"/><s:intercept-url pattern="/common/**" filters="none"/><!-- 配置登录页面!设置always-use-default-target成"true",用户登录后总是会转发到default-target-url指定的位置,无论他们在登录页面之前访问的什么位置。 解决使用局部刷新功能的环境下,用户在Login之后应该自动跳到Login之前访问的安全资源导致的页面只显示局部的问题!--><s:form-login login-page="/login" default-target-url="/index.jsp" authentication-failure-url="/login?error=true" always-use-default-target="true"/><s:logout logout-success-url="/index.jsp"/><!-- 注意:在SS3.0.x中,自定义的filter的配置要放在s:http里 --><s:custom-filter ref="filterSecurityInterceptor" before="FILTER_SECURITY_INTERCEPTOR"/><s:custom-filter ref="reAuthenticationFilter" before="FORM_LOGIN_FILTER"/><!-- TODO 自定义的未授权访问拒绝的处理器 --><s:access-denied-handler ref="accessDeniedHandler"/></s:http><!--<s:http auto-config="true" access-decision-manager-ref="accessDecisionManager"><s:form-login login-page="/logreg.action" default-target-url="/"authentication-failure-url="/logreg.action?error=true" /><s:logout logout-success-url="/" /><s:remember-me key="e37f4b31-0c45-11dd-bd0b-0800200c9a66" /></s:http>--><bean id="reAuthenticationFilter" class="com.leeoo.info_platform.common.web.access.filter.ReAuthenticationFilter"><property name="userDetailsService" ref="userDetailsService" /></bean><bean id="accessDeniedHandler" class="com.leeoo.common.security.AccessDenied4AjaxHandlerImpl"><property name="accessDeniedUrl" value="/common/403.jsp"/></bean><!-- 认证配置,使用userDetailsService提供的用户信息 --><s:authentication-manager alias="authenticationManager"><s:authentication-provider user-service-ref="userDetailsService"><!-- 可设置hash使用sha1或md5散列密码后再存入数据库,默认是不加密的纯文本明文,默认的加密方式请参考BasePasswordEncoder类--><s:password-encoder hash="md5"><!-- 将每个用户的username作为盐值(加密种子) --><s:salt-source user-property="username"/></s:password-encoder></s:authentication-provider></s:authentication-manager><!-- 项目实现的用户查询服务 --><bean id="userDetailsService" class="com.leeoo.info_platform.account.service.UserDetailsServiceImpl" /><!--JCaptcha验证码服务<bean id="captchaService" class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService"><property name="captchaEngine"><bean class="com.zenithen.skynet.skynet.security.jcaptcha.GMailEngine" /></property>默认生成的图片180秒过期 , 可另行设置<property name="minGuarantedStorageDelayInSeconds" value="180" /></bean> --><!-- 重新定义的FilterSecurityInterceptor,使用databaseDefinitionSource提供的url-授权关系定义 --><!-- <bean id="filterSecurityInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor"> SpringSecurity2.0.x中使用 --><bean id="filterSecurityInterceptor" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor"><!--<s:custom-filter before="FILTER_SECURITY_INTERCEPTOR" /><s:custom-filter ref="databaseDefinitionSource" before="FILTER_SECURITY_INTERCEPTOR"/>--><property name="authenticationManager" ref="authenticationManager" /><property name="accessDecisionManager" ref="accessDecisionManager" /><property name="securityMetadataSource" ref="databaseDefinitionSource" /><!-- <property name="objectDefinitionSource" ref="databaseDefinitionSource" /> 注:objectDefinitionSource在SS3中已经标记为过时了,要换用securityMetadataSource --></bean><!-- DefinitionSource工厂,使用resourceDetailsService提供的URL-授权关系. --><!--<bean id="databaseDefinitionSource" class="com.leeoo.info_platform.service.account.DefinitionSourceFactoryBean"><property name="resourceDetailsService" ref="resourceDetailsService" /></bean>--><bean id="databaseDefinitionSource" class="com.leeoo.info_platform.common.web.access.intercept.MyFilterInvocationSecurityMetadataSource"><constructor-arg index="0"><bean class="org.springframework.security.web.util.AntUrlPathMatcher"/></constructor-arg><constructor-arg index="1" ref="resourceDetailsService"/></bean><!-- 项目实现的URL-授权查询服务 --><bean id="resourceDetailsService" class="com.leeoo.info_platform.account.service.ResourceDetailsServiceImpl" /><!-- 授权判断配置, 将授权名称的默认前缀由ROLE_改为A_. --><!-- <bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased"> SpringSecurity2.0.x中使用 --><bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"><property name="decisionVoters"><list><!-- <bean class="org.springframework.security.vote.RoleVoter"> SpringSecurity2.0.x中使用 --><bean class="org.springframework.security.access.vote.RoleVoter"><property name="rolePrefix" value="A_"/></bean><!-- <bean class="org.springframework.security.vote.AuthenticatedVoter" /> SpringSecurity2.0.x中使用 --><bean class="org.springframework.security.access.vote.AuthenticatedVoter" /></list></property></bean>
</beans>

转载于:https://my.oschina.net/leeoo/blog/51026

SpringSecurity3.0.4的An AuthenticationManager is...相关推荐

  1. 自定义springSecurity3.0 登录后自定义返回页面

    使用springSecurity验证登录密码基于SpringMVC模式,在配置文件中默认返回一个页面,但是我们有时候因需求原因需要自定义返回某个页面而不是配置文件中的默认页面,所以我们需要重写Auth ...

  2. CAS单点登录自定义登录页面错误提示

    在工作项目中使用到了单点登录,采用CAS方案,发现输入错误用户名.密码或验证码登录时没有错误提示,经过反复查询资料和尝试,找到了解决方法. 版本介绍 使用的cas版本为: 客户端:cas-client ...

  3. Spring mvc 3.0 入门及应用

    [一]Spring应用 Spring 支持json格式的jar jackson-all-1.7.3  http://jackson.codehaus.org/ Spring MVC 3.x annot ...

  4. SpringSecurity3整合CAS实现单点登录

    SpringSecurity本身已经做好了与CAS的集成工作,只需要我们做简单配置就可以了 步骤1 spring-cas.xml配置文件内容如下(完整版) <?xml version=" ...

  5. spring-security3 配置和使用

    web.xml配置 <context-param> <param-name>contextConfigLocation</param-name> <param ...

  6. oracle access manager token,AuthenticationManager验证原理

    AuthenticationManager相关类图 AuthenticationManager验证过程 AuthenticationManager验证过程涉及到的类和接口较多,我们就从这里开始逐一分析 ...

  7. oauth2.0源码分析之oauth/token申请令牌

    本期介绍的是在oauth2.0中 , 通过调用oauth/token接口 , 框架是如何给我们申请到JWT令牌的 , 内部做了些什么事情 ? 在分析源码之前 , 我们首先需要知道的是我们需要具备哪些调 ...

  8. 估算带卷积核二分类0,3的网络的收敛时间和迭代次数

    制作一个网络分类minst的0和3求出这网络的迭代次数曲线表达式n(δ),和准确率表达式p-max(δ),用预期准确率去估算n,并推算需要的时间. 将minst的28*28的图片缩小到9*9,网络用一 ...

  9. spring 的权限控制:security

    下面我们将实现关于Spring Security3的一系列教程.  最终的目标是整合Spring Security + Spring3MVC  完成类似于SpringSide3中mini-web的功能 ...

  10. 使用Spring Security3的四种方法概述

    使用Spring Security3的四种方法概述 那么在Spring Security3的使用中,有4种方法: 一种是全部利用配置文件,将用户.权限.资源(url)硬编码在xml文件中,已经实现过, ...

最新文章

  1. muduo:获取进程相关信息
  2. Bootstrap的目录结构
  3. 2021考研 计算机国家线解读及对应策略
  4. 第六次 Scrum Meeting
  5. Range.EntireRow Property
  6. 性能VS功能,同为测试又有哪些不一样?
  7. 纪念一下我这尴尬中二的排名吧
  8. echarts配合循环计时器等出现的内存泄漏
  9. myeclipse 8.0GA 安装注册步骤
  10. web前端开发视频教程完整54讲下载
  11. 中兴新支点Linux国产操作系统安装windows字体的方法
  12. Ubuntu 桌面截屏(或截图)的方式
  13. altium怎么锁定_在AD软件中的锁定与解锁命令应该如何使用?
  14. Justinmind,为移动设计而生
  15. windows7未能连接一个windows服务(无法连接网络)的解决方法
  16. 系统集成项目管理工程师学习建议
  17. Information Retrieval(信息检索)笔记02:Preprocessing and Tolerant Retrieval
  18. Mixly第三方库开发的两种方法——U8g2库二次开发
  19. Docker 无法启动 Failed to start LSB: Create lightweight, portable, self-sufficient containers.
  20. SAP中英文环境配置

热门文章

  1. poj1990两个树状数组
  2. android:异步任务asyncTask介绍及异步任务下载图片(带进度条)
  3. ACM学习历程—HDU1584 蜘蛛牌(动态规划 状态压缩 || 区间DP)
  4. 內嵌html字符串顯示
  5. spring mvc 学习 转载
  6. Dubbo + Zookeeper 简单搭建
  7. 109 进程的并行和并发
  8. IDEA SpringBoot多模块项目搭建详细过程(转)
  9. CentOS6和CentOS7进入单用户模式重置root密码
  10. oracle 中 cursor 与refcursor及sys_refcursor的区别 (转载)