Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

PrimaryDefaultValidatorPostProcessor triggered at different time with AOT leads to incomplete Validator bean definition #1243

Closed
OlgaMaciaszek opened this issue Nov 9, 2021 · 3 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@OlgaMaciaszek
Copy link
Contributor

In this sample, in AOT mode, NoUniqueBeanDefinition is thrown for Validator beans, even though one of the two is annotated with @ConditionalOnMissingBean:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'integrationMessageHandlerMethodFactory': Unsatisfied dependency expressed through method 'messageHandlerMethodFactory' parameter 1; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.validation.Validator' available: expected single matching bean but found 2: defaultValidator,mvcValidator

@OlgaMaciaszek OlgaMaciaszek added this to the 0.11.0-RC1 milestone Nov 9, 2021
@snicoll snicoll changed the title @ConditionalOnMissingBean ignored for validator beans PrimaryDefaultValidatorPostProcessor triggered at different time with AOT leads to incomplete Validator bean definition Nov 9, 2021
@snicoll snicoll removed their assignment Nov 9, 2021
@snicoll
Copy link
Contributor

snicoll commented Nov 15, 2021

The problem is a different order of processing for BeanDefinitionRegistryPostProcessor. I have changed a custom code to use a callback of framework and that fixed the issue. Unfortunately, calling these has the side effects of contributing quite some more bean definitions, certain with not the type I'd expect. I am investigating.

@snicoll snicoll self-assigned this Nov 15, 2021
@snicoll
Copy link
Contributor

snicoll commented Nov 18, 2021

This was already fixed as part of #1213 but I've added a test to validate the behaviour. @OlgaMaciaszek your sample app still doesn't work unfortunately as Spring Integration is not yet supported.

@OlgaMaciaszek
Copy link
Contributor Author

Ok - the users will need to wait till that's done then for these kinds of projects. Anyway, that user-provided sample has allowed us to discover and fix at least 3 different issues :) . Thanks, @matus753.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Development

No branches or pull requests

2 participants