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

Circular reference error when autowiring JobBuilderFactory #3991

Closed
cppwfs opened this issue Sep 7, 2021 · 0 comments
Closed

Circular reference error when autowiring JobBuilderFactory #3991

cppwfs opened this issue Sep 7, 2021 · 0 comments
Labels
has: minimal-example Bug reports that provide a minimal complete reproducible example in: core type: bug
Milestone

Comments

@cppwfs
Copy link
Contributor

cppwfs commented Sep 7, 2021

Scenario

When a user autowires JobBuilderFactory and StepBuilderFactory in a Java configuration where one of the beans required by the batch application is in the same configuration, boot throws a BeanCurrentlyInCreationException.
Starting in Spring Boot 2.6.M2, boot checks for circular references by default ( spring.main.allow-circular-references=false) . In previous releases of spring boot the spring.main.allow-circular-references was defaulted to true.

Sample Application

A sample application can be found here: https://github.com/cppwfs/batchsamp


EDIT: Related SO thread: https://stackoverflow.com/questions/69379794

@cppwfs cppwfs added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Sep 7, 2021
cppwfs pushed a commit to cppwfs/spring-cloud-task that referenced this issue Sep 7, 2021
Makes sure that dependencies are passed in via parameters in bean declaraction vs. Autowiring

refer to spring-projects/spring-batch#3991
resolves spring-cloud#797
cppwfs pushed a commit to cppwfs/spring-cloud-task that referenced this issue Sep 7, 2021
Makes sure that dependencies are passed in via parameters in bean declaraction vs. Autowiring

refer to spring-projects/spring-batch#3991
resolves spring-cloud#797
@fmbenhassine fmbenhassine added has: minimal-example Bug reports that provide a minimal complete reproducible example in: core and removed status: waiting-for-triage Issues that we did not analyse yet labels Sep 8, 2021
@fmbenhassine fmbenhassine added this to the 5.0.0 milestone Sep 8, 2021
cppwfs pushed a commit to cppwfs/spring-cloud-task that referenced this issue Sep 16, 2021
Makes sure that dependencies are passed in via parameters in bean declaraction vs. Autowiring

refer to spring-projects/spring-batch#3991
resolves spring-cloud#797

Updated based on code review
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Apr 25, 2022
Before this commit, the datasource was autowired in
AbstractBatchConfiguration. This was causing context
startup failures when no datasource or more than one
datasource is present in the context.

This commit fixes these failures by looking for the
datasource in the application context. This also
prevents cyclic configuration dependencies when
the datasource bean is defined in the same class where
other batch artifacts are autowired.

Issue spring-projects#3991
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue May 9, 2022
Before this commit, the datasource was autowired in
AbstractBatchConfiguration. This was causing context
startup failures when no datasource or more than one
datasource is present in the context.

This commit fixes these failures by looking for the
datasource in the application context. This also
prevents cyclic configuration dependencies when
the datasource bean is defined in the same class where
other batch artifacts are autowired.

Issue spring-projects#3991
@fmbenhassine fmbenhassine modified the milestones: 5.0.0, 5.0.0-M3 May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: minimal-example Bug reports that provide a minimal complete reproducible example in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants