Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating bean with name 'springSecurityFilterChain' #68

Closed
fanhualei opened this issue Jan 23, 2018 · 17 comments
Closed

Error creating bean with name 'springSecurityFilterChain' #68

fanhualei opened this issue Jan 23, 2018 · 17 comments

Comments

@fanhualei
Copy link

idea new project from github .

run auth-server print error why?

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-01-23 10:40:45.538 ERROR 5905 --- [ main] o.s.boot.SpringApplication : Application startup 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.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]

@dsyer
Copy link
Collaborator

dsyer commented Jan 23, 2018

What version of Java are you using? JAXB is included in most Java 8 distros, but is missing from Java 9.

@fanhualei
Copy link
Author

Thank you, use jdk8 , there is no Error 。

At first, I was using jdk9, it print :Error creating bean with name 'springSecurityFilterChain'

@alhezmi72
Copy link

alhezmi72 commented Feb 1, 2019

The same error occurs by using openjdk version "10.0.2". I am using spring-boot-starter-parent:2.1.2.RELEASE. The exception appears only in the Hosting an Authorization Server part and especially by adding the injection: @EnableAuthorizationServer.

@dsyer
Copy link
Collaborator

dsyer commented Feb 1, 2019

You need Java 8 still. Same for all the guides in spring.io.

@williambm
Copy link

williambm commented Sep 10, 2019

If you are using maven you can put thats dependecies into your project

<dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.0</version> </dependency> <!-- JAXB needs javax.activation module (jdk9) --> <dependency> <groupId>javax.activation</groupId> <artifactId>javax.activation-api</artifactId> <version>1.2.0</version> </dependency>

@Vipisanan
Copy link

first, thank you
after adding these dependencies it's working 👍
but I don't know what's happing
this error means
Error creating bean with name 'springSecurityFilterChain'

@luxus0
Copy link

luxus0 commented Oct 16, 2019

remove from class "extends WebSecurityConfigurerAdapter" and @OverRide and program will compile :)

@Vipisanan
Copy link

thank you I'll check :) @luxus0

@amineBenabdalllah
Copy link

amineBenabdalllah commented Dec 20, 2019

remove from class "extends WebSecurityConfigurerAdapter" and @OverRide and program will compile :)

Thanks man

@ltpitt
Copy link

ltpitt commented Apr 17, 2020

You are the king, @luxus0

Works for me on Java 11.

@JackyTran8594
Copy link

It's working , but why ? I don't know what's happing
pls, explaining it for me :(((

@dsyer
Copy link
Collaborator

dsyer commented Dec 20, 2020

See above. JAXB is not included with Java 9 and above (but you can add it as an external dependency).

@JackyTran8594
Copy link

See above. JAXB is not included with Java 9 and above (but you can add it as an external dependency).

Hi dsyer! I have an error about creating bean with name 'springSecurityFilterChain'. this error is below:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-12-22T11:04:48.076+0700 ERROR 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.IllegalStateException: At least one SecurityBuilder<? extends SecurityFilterChain> needs to be specified. Typically this is done by exposing a SecurityFilterChain bean or by adding a @configuration that extends WebSecurityConfigurerAdapter. More advanced users can invoke WebSecurity.addSecurityFilterChainBuilder directly.

I fixed this by adding @configuration in CustomSecurityConfigurerAdapter class that extends WebSecurityConfigurerAdapter, but it's not working. Pls, help me fix this ! Thank you very much

@dsyer
Copy link
Collaborator

dsyer commented Dec 22, 2020

Then that’s different to the exception reported here. If you want general help with Spring Boot and security you should try stack overflow or maybe gitter.im.

@pablohdzvizcarra
Copy link

If you are using maven you can put thats dependecies into your project

<dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.0</version> </dependency> <!-- JAXB needs javax.activation module (jdk9) --> <dependency> <groupId>javax.activation</groupId> <artifactId>javax.activation-api</artifactId> <version>1.2.0</version> </dependency>

this works for me

@Tonio12
Copy link

Tonio12 commented Sep 30, 2023

Didnt work for me using Java17

@luxus0
Copy link

luxus0 commented Sep 30, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests