spring-projects / spring-projects/spring-hateoas
BeanPostProcessor bean declaration that retrieves object from injected ObjectFactory with bounded type parameter results in missing PluginRegistry bean during application startup
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
Given:
- a Spring-Boot project
- using Spring-HATEOAS
When:
- there is a BeanPostProcessor bean declaration
- which gets an ObjectFactory with bounded type parameter injected
- where getObject() is called on the injected ObjectFactory
Then:
- application startup fails with error
Parameter 0 of method _relProvider in org.springframework.hateoas.config.HateoasConfiguration required a bean of type 'org.springframework.plugin.core.PluginRegistry' that could not be found..
The following example bean declaration will cause the error:
@Bean
public BeanPostProcessor exampleBeanPostProcessor(ObjectFactory<? extends ExampleComponent> exampleComponentObjectFactory) {
exampleComponentObjectFactory.getObject();
return new BeanPostProcessor() {};
}
Any of the following alterations to the bean declaration will avoid the error:
- using a non-bounded type parameter
- not calling getObject() on the ObjectFactory
- declaring a bean of a type not BeanPostProcessor
Complete error message:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method _relProvider in org.springframework.hateoas.config.HateoasConfiguration required a bean of type 'org.springframework.plugin.core.PluginRegistry' that could not be found.
The following candidates were found but could not be injected:
- User-defined bean method 'relProviderPluginRegistry' in 'HateoasConfiguration'
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.plugin.core.PluginRegistry' in your configuration.
Minimal example project: https://github.com/VTLob/spring-hateoas-issue
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the startup failure in the linked minimal example project with the bounded ObjectFactory BeanPostProcessor declaration. Compare the listed declaration variations and trace why calling getObject() prevents the PluginRegistry bean from being injected. Done means the example starts successfully with the original scenario and the PluginRegistry is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100