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

Early initialization of @Configuration class may lead to unwanted call to setBeanFactory [SPR-12445] #17050

Closed
spring-projects-issues opened this issue Nov 17, 2014 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Thomas Demande opened SPR-12445 and commented

Cf GitHub sample project referenced in the Reference URL.

The scenario I face is that I have some configuration stored in a specific Git repository, which is used by the application. For performances reasons (JGit usage seems rather slow) , the idea is to perform a first find at startup then use a cache/refresh technique later on.

When using an InitializingBean, the application startup fails with a

Caused by: java.lang.NoSuchMethodError:
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
.setBeanFactory(Lorg/springframework/beans/factory/BeanFactory;)V

It can easily be reproduced by launching mvn spring-boot:run in the GitHub sample.


Affects: 4.1.2

Reference URL: https://github.com/tdemande/spring-config-server

Referenced from: commits c1f1cac

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

What happens is that the CGLIB proxy that we create for the EnhancedConfiguration tries to call the setBeanFactory method even though this method is not defined on the actual class.

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Alright, we found some application context destruction callback weirdness as the findOne your afterPropertiesSet method actually starts a context and closes it with PropertyPlaceholderAutoConfiguration. This has a (unwanted) impact on the PropertyPlaceholderAutoConfiguration instance of the "main" context. Juergen and I did some digging and we found a way to fix that. Trying it now.

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

It turns out that the static registration/cleanup arrangement for the CGLIB interceptors were flawed in a specific use case (the findOne method is actually creating a context and disposing it and this had side effect on the main context as this one done in a afterPropertiesSet method).

Your sample application now works fine against master. Thanks for the report!

@spring-projects-issues
Copy link
Collaborator Author

Thomas Demande commented

Yep, works fine with 4.1.3.BUILD-SNAPSHOT, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants