“springSecurityFilterChain”抛出异常;嵌套异常是 java.lang.IllegalArgumentException:提供程序列表不能包含空值

2024-01-16

在启动 SpringBoot 应用程序时,我不断收到以下错误。

与我有关吗SpringWebSecurityConfig文件??以下是文件内容。

@Configuration
public class SpringWebSecurityConfig extends WebSecurityConfigurerAdapter {
  private AuthenticationProvider authenticationProvider;

  @Autowired
  @Qualifier("daoAuthenticationProvider")
  public void setAuthenticationProvider(AuthenticationProvider authenticationProvider) {
    this.authenticationProvider = authenticationProvider;
  }

  @Bean
  public PasswordEncoder passwordEncoder() {
    PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    return passwordEncoder;
  }

  @Bean("daoAuthenticationProvider")
  public AuthenticationProvider daoAuthenticationProvider(UserDetailsService userDetailsService) {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder(passwordEncoder());
    provider.setUserDetailsService(userDetailsService);
    return provider;
  }

  @Autowired
  public void configureAuthManager(AuthenticationManagerBuilder authenticationManagerBuilder) {
    authenticationManagerBuilder.authenticationProvider(authenticationProvider);
  }

  @Override
  protected void configure(HttpSecurity httpSecurity) throws Exception {
    httpSecurity.authorizeRequests()
            .antMatchers("/").permitAll()
            /*.antMatchers("/","/products", "/product/show/*", "/console/*", "/h2-console/**")
                .permitAll().anyRequest().authenticated()*/
            .and()
                .formLogin().loginPage("/login")
                //.formLogin().loginPage("/login").successHandler(customSuccessHandler)
            .and()
                .logout().permitAll()
            .and()
                .exceptionHandling().accessDeniedPage("/error/403");


    httpSecurity.csrf().disable();
    httpSecurity.headers().frameOptions().disable();
  }
}
'''

异常堆栈跟踪:

2020-06-11 21:40:41.401  INFO 1240 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-06-11 21:40:41.403  WARN 1240 --- [  restartedMain] ConfigServletWebServerApplicationContext : **Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: providers list cannot contain null values**
2020-06-11 21:40:41.404  INFO 1240 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

2020-06-11 21:40:42.934  INFO 1240 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-06-11 21:40:42.944  INFO 1240 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-06-11 21:40:42.952  INFO 1240 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
Exception in thread "task-2" org.springframework.beans.factory.BeanCreationNotAllowedException: **Error creating bean with name 'springApplicationAdminRegistrar': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)**
    (...)
2020-06-11 21:40:43.183  WARN 1240 --- [  restartedMain] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200]
2020-06-11 21:40:43.185  INFO 1240 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2020-06-11 21:40:43.200  INFO 1240 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2020-06-11 21:40:43.206  INFO 1240 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-06-11 21:40:43.232  INFO 1240 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-11 21:40:43.257 ERROR 1240 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

**org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: providers list cannot contain null values**
    (...)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: providers list cannot contain null values
    (...)
Caused by: java.lang.IllegalArgumentException: providers list cannot contain null values
    (...)

2020-06-11 21:40:43.265  WARN 1240 --- [  restartedMain] o.s.boot.SpringApplication               : Unable to close ApplicationContext

**org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available**
    (...)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    (...)
Caused by: **org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    (...)


Process finished with exit code 0

EDIT:1

我确信这是原因@Bean("daoAuthenticationProvider")。似乎这个 bean 在服务器启动时不可用,或者在其依赖之后被加载。我尝试使用 @DependsOn 注释,但这会带来循环依赖问题。

下面是抛出此异常的 spring jar。 org.springframework.security.authentication.ProviderManager#checkState

  private void checkState() {
        if (parent == null && providers.isEmpty()) {
            throw new IllegalArgumentException(
                    "A parent AuthenticationManager or a list "
                            + "of AuthenticationProviders is required");
        } else if (providers.contains(null)) {
            throw new IllegalArgumentException(
                    "providers list cannot contain null values");
        }
    }

请指导我,因为此问题导致服务器间歇性启动失败。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“springSecurityFilterChain”抛出异常;嵌套异常是 java.lang.IllegalArgumentException:提供程序列表不能包含空值 的相关文章

  • 为什么从 Eclipse 导出的可运行 JAR 不起作用?

    我有一个在 Eclipse 中运行良好的项目 但是 当我将其导出到可运行的 JAR 其中包含依赖项 时 它不会运行 从控制台运行 JAR 时出现的错误是 编辑 之前没有使用 jar 运行它 INFO Loading XML bean def
  • jUnit 中每个 @Test 的不同拆卸

    有没有办法为 jUnit 中的每个 Test 定义不同的拆卸 Use the After注释来指示每个之后要运行的方法 Test 像这样的全套注释是 BeforeClass 首先 Tests are run Before 在每个之前 Tes
  • 如何使用 hibernate 过滤器过滤 hibernate 中的实体

    我需要过滤对象列表中的实体 例如 public class Student private int id private List
  • 从 java.util.TimeZone 转换为 org.joda.DateTimeZone

    在Java中如何将一个实例转换为java util TimeZone to org joda DateTimeZone并保持夏令时 Joda Time 处于维护模式 The 乔达时间 http www joda org joda time
  • Java 内存错误:无法创建新的本机线程

    运行 java 服务器时 我在 UNIX 服务器上收到此错误 Exception in thread Thread 0 java lang OutOfMemoryError unable to create new native threa
  • 如何跨工作区保存 E​​clipse 启动配置文件?

    当我复制 Eclipse 项目目录时 它包含 classpath 和 project 文件 这样当我将同一目录带到另一个 Eclipse 实例时 我不必设置我的构建路径等 假设所有资源都包含在在项目中 而不是外部 但是 此过程不会导致启动配
  • Spring 在 AuthenticationSuccessHandler 中自动装配会话范围 bean 不起作用

    我正在使用 spring security 我想初始化一个对象User在用户成功登录后的会话中 安全配置如下 Configuration EnableWebSecurity PropertySource classpath configs
  • 使用 Gradle 构建 Kotlin + Java 9 项目

    我对 Gradle 老实说 还有 Java 9 相当陌生 我正在尝试使用 Gradle 构建一个混合了 Java 9 和 Kotlin 的简单库项目 更详细地说 Java中有一个接口 Kotlin中有一个实现 我会用 Kotlin 做所有事
  • Java 会话变量

    我听说有些人认为在会话中将信息存储在服务器上是一个坏主意 因为它不安全 因此 在多页面业务流程功能中 应用程序将数据写入数据库 然后在需要时检索信息 在会话中存储私人信息是否一定不安全 只要会话本身安全 在会话中存储属性就不存在安全风险劫持
  • HttpMediaTypeNotAcceptableException / HttpMediaTypeNotAcceptableException:找不到可接受的表示

    我有一个客户端正在尝试连接的 API 但是它会抛出错误 2015 09 22 04 21 44 297 org springframework web servlet mvc method annotation HttpEntityMeth
  • spring-hibernate 花费更多时间的任何原因?

    目前 我正在春季和冬眠期间从事一个项目 我来到这里 获取记录并在 JSP 中显示这些记录需要更多时间 我在各处都保留了时间戳 以查看哪里花费了更多时间 Time HomeController start 2014 07 09 18 58 5
  • 如何删除 Spring 的 RestTemplate 添加的某些 HTTP 标头?

    我在远程服务方面遇到问题 我无法控制对使用 Spring 的 RestTemplate 发送的请求进行 HTTP 400 响应 使用发送的请求curl但被接受了 所以我将它们与通过 RestTemplate 发送的内容进行了比较 特别是 S
  • 选择活动时运行时崩溃

    首先我想说我几乎没有 Android 经验 这是我在 Android 中的第一个项目 而且我的老师不太擅长教学 所以我对任何过度的无知表示歉意 在进一步讨论之前先解释一下 我的应用程序的目标本质上是能够记录您在某些活动上花费了多少时间 记录
  • Spring boot 2.1.x 如何通过基本身份验证保护执行器端点

    我正在尝试构建一个 Spring Boot 应用程序 并希望利用 Actuator 功能 但我想保护 Actuator health shutdown 等的端点 我有以下配置 但似乎不起作用 也就是说 应用程序从不提示输入凭据 或者当邮递员
  • 从 Spring 启动运行 Java 类

    我使用的是Java8和Spring4 3 1 我有一个 Java Spring 应用程序托管由浏览器和移动应用程序客户端访问的 RESTfult 服务 其次 我编写了一个侦听事件的聊天服务器 socket io 来自客户 该聊天服务器正在从
  • 使用用户名和密码登录 LinkedIn 失败

    LinkedIn使用oauth登录其api 服务器中无法登录api 我尝试使用http请求登录linkedin并获取oauth verifier 但我得到了这样的回应 很抱歉 出现了问题 你的申请 请确保您 启用cookie并重试 或点击此
  • 找不到 `activityViewModels()` Hilt Android

    我在我的项目中使用 Hilt 和 MVVM 我想要一个viewModel from activityViewModel在 2 个活动中使用相同的内容 但我的 Android Studio 说未解析的参考 我的应用程序 build gradl
  • 如何在android中使用Room Persistence ORM工具实现created_at和updated_at列

    我该如何实施created at and updated at在Android中使用Room Persistence ORM工具的列 可以在创建或更新表中的行时自动更新时间戳 我研究了很多网站 但仍然没有找到任何可以处理的结果middlew
  • java有类似C#的属性吗? [复制]

    这个问题在这里已经有答案了 C 属性 我的意思是 get 和 set 方法 是一个非常有用的功能 java 也有类似 C 的属性吗 我的意思是我们如何在 java 中实现类似以下 C 代码的内容 public string Name get
  • 应用服务器如何注入私有字段?

    我看到这个问题 注入私有 包或公共字段或提供 setter https stackoverflow com questions 2021716 inject into private package or public field or p

随机推荐

  • C# 在运行时获取进程输出

    无论如何 是否可以重定向生成进程的标准输出并在发生时捕获它 我所看到的一切都只是在该过程完成后执行 ReadToEnd 我希望能够在打印时获得输出 Edit private void ConvertToMPEG Start the chil
  • Android 内存不足异常

    有什么办法可以处理吗OutOfMemoryException在Android中同时使用大量图片的Bitmap 我尝试了本网站给出的所有解决方案 即 GC Bitmap reset 我只是想知道在堆内存即将满之前是否可以生成警报 这样我就可以
  • ABAP ADT 先决条件?

    在 Eclipse 中建立与本地数据库的连接以开始在 ABAP 中进行开发需要什么 我已经安装了 ABAP 插件 但无法连接到数据库 有什么建议么 ABAP 开发工具 ADT https tools hana ondemand com ab
  • 从 Ada 程序启动可执行文件并读取结果

    I found this https stackoverflow com questions 32663224 why isnt my gnats standout file descriptor working问题和第一个答案包含一些示例
  • 在jqgrid中添加行

    我正在使用 jqGrid 并且它工作正常 我有一个场景 我必须在 jqGrid 中添加一个空白行 而不是弹出窗口来添加行 我该怎么做 您可以使用例如添加行数据 http www trirand com jqgridwiki doku php
  • 用C将客户端输入插入MySQL数据库

    如何编写一个 C 程序来获取 MySQL 服务器的客户端输入 我使用 Fedora 作为我的操作系统 这是我的代码 include
  • 如何判断 ASP.NET 应用程序中的 HTTP 标头何时已发送?

    长话短说 我有一个 ASP NET 应用程序 我正在尝试调试 在某些时候 在非常特殊的情况下 该应用程序将抛出异 常Response Redirect 陈述 Cannot redirect after HTTP headers have b
  • 如何使用 Linq 选择具有一对多关系的所有内容

    我有两张桌子 CREATE TABLE Thing Id int Name nvarchar max CREATE TABLE SubThing Id int Name nvarchar max ThingId int foreign ke
  • Google 地图未完全呈现在页面上?

    我的页面上有一个谷歌地图 其中有一个我自己构建的搜索窗格 可以随意显示和隐藏 假设它的一侧覆盖了地图的 200 个像素 问题是 当我调整地图大小时 窗格重叠的区域不会渲染 即地图由于某种原因不会在那里渲染 看看这个link http www
  • 如何将 .XLS 和 .XLSX 文件转换为 .PDF 格式并将它们返回到 Powershell 中的每个原始子文件夹?

    我目前有一个 powershell 脚本 可以很好地将 Excel 电子表格转换为 PDF 文件 但我的问题是新文件出现在父文件夹中 而不是它们来自的特定子文件夹中 我当前的脚本如下所示 path c users me Documents
  • 在 PostgreSQL 中对 JsonB 数组进行 Sequelize ORM 查询

    如何使用一些匹配条件和逻辑运算 lt et gte等 在 Jsonb 对象数组上 在 PostgreSQL 中使用 Sequelize ORM 表名 calls id direction metaData 1 inbound 2 outbo
  • 使用 Javascript 比较 HTML 中的两个输入数字?

    我正在使用 Notepad 创建一个简单的网页 用户在文本框中输入两个数字 然后按下按钮 当他们按下按钮时 会出现一些信息 告诉他们第一个数字还是第二个数字更大 我有以下代码 但无法得到任何结果 有谁知道出了什么问题吗
  • XML 新版本 - 新功能

    XML 有新版本了吗 如果是的话 它是什么时候发布的 有哪些新功能 目前 基本 XML 规范中的新功能不太可能出现 当然 XML 系列中的其他标准将会继续发展 但 XML 本身非常稳定 该标准有多个 版本 到目前为止为止是第五版 但这些仅仅
  • 如何在编译时推断嵌套 std::vector 的内部类型?

    有一天我问了一个非常类似的问题 https stackoverflow com questions 59490698 how can i get the depth of a multidimensional stdvector at co
  • 将多维数组转换为字符串并返回

    我有一个二维数组 我需要能够将其转换为字符串表示形式并返回数组格式 我想创建一个通用方法来处理任何数组 1d 2d 3d 等 这样我将来就可以重用该方法 解决这个问题的最佳方法是什么 string array new string help
  • 手动添加声明文件 (TypeScript)

    我没有找到 google spreadsheet 的声明文件 因此我尝试自己创建一个 在打字 gt 模块中 我添加了一个名为 google spreadsheet 的新文件夹 并在其中添加了一个名为 index d ts 的新文件 其中包含
  • 更新 Spring 注入的属性文件以包含上次运行时间戳

    我有一个应用程序 它使用 Spring 加载的属性文件 然后将 Properties 实例注入到几个类中 问题是其中一些属性已更新 例如我们有一个要存储在这里的lastRun时间戳 也许有更好的方法来存储这样的东西 欢迎建议 但是我该如何更
  • 对于具有相同分数的文档,主/副本的结果顺序不一致

    我创建了一个包含单个分片和 1 个副本的索引 我正在运行 ElasticSearch 版本 1 0 1 并且集群有 3 个节点 我注意到 有时具有相同分数的文档的结果排序是 根据是否针对主数据库和副本数据库运行相同的查询而有所不同 该查询是
  • 从 System.Windows.Media.Geometry 获取坐标列表

    Given a System Windows Media Geometry类实例 有没有一种简单的方法可以将其转换为轮廓和点列表 例如 我怎样才能简单地将其分解为一个列表LineSegments用于自定义渲染 FormattedText f
  • “springSecurityFilterChain”抛出异常;嵌套异常是 java.lang.IllegalArgumentException:提供程序列表不能包含空值

    在启动 SpringBoot 应用程序时 我不断收到以下错误 与我有关吗SpringWebSecurityConfig文件 以下是文件内容 Configuration public class SpringWebSecurityConfig