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

BeanCreationException when putting the jar into the classpath (but not adding an annotation) #72

Open
ePaul opened this issue Feb 23, 2018 · 1 comment
Labels
auto-configuration everything about the auto-configuration features bug spring-boot-1 Issues/PRs which only apply to the Spring-Boot 1 versions (Releases < 20.0)

Comments

@ePaul
Copy link
Member

ePaul commented Feb 23, 2018

Wrong behavior
When just putting the jar into the classpath (e.g. by adding a maven dependency), but not adding the @EnableNakadiProducer annotation, a spring-boot app will fail during the startup.

Error message:

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 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping]: Factory method 'endpointHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcEndpoints' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'snapshotEventCreationMvcEndpoint' defined in class path resource [org/zalando/nakadiproducer/NakadiProducerAutoConfiguration$ManagementEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'snapshotEventCreationMvcEndpoint' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'snapshotEventCreationEndpoint' defined in class path resource [org/zalando/nakadiproducer/NakadiProducerAutoConfiguration$ManagementEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'snapshotEventCreationEndpoint' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.zalando.nakadiproducer.snapshots.impl.SnapshotCreationService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method snapshotEventCreationEndpoint in
 org.zalando.nakadiproducer.NakadiProducerAutoConfiguration$ManagementEndpointConfiguration
 required a bean of type 'org.zalando.nakadiproducer.snapshots.impl.SnapshotCreationService' that
 could not be found.


Action:

Consider defining a bean of type 'org.zalando.nakadiproducer.snapshots.impl.SnapshotCreationService'
 in your configuration.

Analysis

The main thing NakadiProducerAutoConfiguration is only activated when the @EnableNakadiProducer annotation is used. But it looks like the inner class ManagementEndpointConfiguration (which is annotated with @ManagementContextConfiguration) is used anyways (maybe just in some circumstances), and this fails because the SnapshotCreationService bean is then missing.

This might be related to the spring.factories file which mentions it.

@ePaul ePaul added bug auto-configuration everything about the auto-configuration features labels Jul 4, 2018
@ePaul
Copy link
Member Author

ePaul commented Jul 18, 2018

If my analysis above is correct, this should now be solved in the 20.0.0 release for spring-boot 2 (because that is not using the @ManagementContextConfiguration anymore).

It is still open in the 4.x release series.

@ePaul ePaul added the spring-boot-1 Issues/PRs which only apply to the Spring-Boot 1 versions (Releases < 20.0) label Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-configuration everything about the auto-configuration features bug spring-boot-1 Issues/PRs which only apply to the Spring-Boot 1 versions (Releases < 20.0)
Projects
None yet
Development

No branches or pull requests

1 participant