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

ShiroWebAutoConfiguration causes springboot to fail to start #1031

Closed
Kevan807680925 opened this issue Aug 10, 2023 · 4 comments
Closed

ShiroWebAutoConfiguration causes springboot to fail to start #1031

Kevan807680925 opened this issue Aug 10, 2023 · 4 comments

Comments

@Kevan807680925
Copy link

When I start the app, I get the following error:
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroEventBusAwareBeanPostProcessor' defined in class path resource [org/apache/shiro/spring/boot/autoconfigure/ShiroBeanAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizationAttributeSourceAdvisor' defined in class path resource [org/apache/shiro/spring/boot/autoconfigure/ShiroAnnotationProcessorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'authorizationAttributeSourceAdvisor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [org/apache/shiro/spring/config/web/autoconfigure/ShiroWebAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.mgt.SessionsSecurityManager]: Factory method 'securityManager' threw exception; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'authorizer' available

When I added the following configuration, it started fine:
@bean
@ConditionalOnBean(Authorizer.class)
@OverRide
protected SessionsSecurityManager securityManager(List realms) {
return super.securityManager(realms);
}
I also suspect that the writing of super.securityManager(realms) affects the dependency analysis of spring, causing the securityManager to be instantiated before the Authorizer

@lprimak
Copy link
Contributor

lprimak commented Aug 16, 2023

We would appreciate a PR if you can do that

@fpapon
Copy link
Member

fpapon commented Nov 13, 2023

@Kevan807680925 can you give us more information about the test? (Shiro version, Spring version, providing a pom.xml or a sample project to reproduce...)

@bdemers
Copy link
Member

bdemers commented Nov 13, 2023

Have you defined a Realm bean?

@lprimak
Copy link
Contributor

lprimak commented Dec 20, 2023

Superseded by #1236

@lprimak lprimak closed this as completed Dec 20, 2023
@lprimak lprimak closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
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

4 participants