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

DatabaseInitializationDependencyConfigurer triggers eager initialization of factory beans #28977

Closed
laurentschoelens opened this issue Dec 10, 2021 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@laurentschoelens
Copy link

I've got a problem from migrating from SB 2.3 to 2.5 branch.

When having a Database with Spring-jdbc in my java applications, CXF JAX-WS clients being initialized with XML config were stopped working since address being populated with the ${placeholder} instead of real value defined in properties.

For me, this is caused by DatabaseInitializationDependencyConfigurer.
It gets all DependsOnDatabaseInitializationDetector and the AnnotationDependsOnDatabaseInitializationDetector is causing eagerInit called before properties are parsed.

 - org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector.detect(ConfigurableListableBeanFactory)
 - org.springframework.beans.factory.ListableBeanFactory.findAnnotationOnBean(String beanName, Class<A> annotationType)
 - org.springframework.beans.factory.support.DefaultListableBeanFactory.findMergedAnnotationOnBean(String beanName, Class<A> annotationType)
 - org.springframework.beans.factory.support.AbstractBeanFactory.getType(String name)
 - org.springframework.beans.factory.support.AbstractBeanFactory.getType(String name, boolean allowFactoryBeanInit)

--> second param allowFactoryBeanInit is true here

Currently under Java 8 using SpringBoot 2.5.7.

Could you please provide a fix for this ?

Making XML Config to Java Config gives me a workaroung but not a real solution to fix this regression.
Overring SpringBoot DatabaseInitializationDependencyConfigurer with empty class also fixes the problem.

I've managed to create a simple example of this issue, I'll send it very soon.

Thanks in advance

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 10, 2021
@laurentschoelens
Copy link
Author

laurentschoelens commented Dec 10, 2021

demo-issue28977.zip
Here is a working example to reproduce the issue with one project having Java Config (working) and another one having XML Config (fail)

When downgrading to SB 2.4 : both apps are working

@wilkinsona wilkinsona changed the title DatabaseInitializationDependencyConfigurer triggers eager initialization of jaxws-client defined in XML config DatabaseInitializationDependencyConfigurer triggers eager initialization of factory beans Dec 10, 2021
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 10, 2021
@wilkinsona wilkinsona added this to the 2.5.x milestone Dec 10, 2021
@wilkinsona
Copy link
Member

wilkinsona commented Dec 10, 2021

This branch contains a fix for this issue. If spring-projects/spring-framework#27796 provides a method to find an annotation without initializing factory beans some of the changes will no longer be necessary.

@laurentschoelens
Copy link
Author

@wilkinsona : thanks, i'll wait 2.5.8 SB release to pick up the fix and delay my upgrade :)

@snicoll
Copy link
Member

snicoll commented Dec 17, 2021

@laurentschoelens thanks for the sample. I was able to build it with the latest change and it is working as expected now.

@laurentschoelens
Copy link
Author

Thanks @snicoll
I've experienced issue creation last year with Spring Boot so I wanted no one to waste time and my bug to be cleared as possible.
I look forward to update SB 2.5.8 now

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

No branches or pull requests

4 participants