Skip to content

Improve error message when bean initialization fails [SPR-9891] #14524

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

Closed
spring-projects-issues opened this issue Oct 19, 2012 · 3 comments
Closed
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Oct 19, 2012

Piotr Findeisen opened SPR-9891 and commented

When bean initialization fails due to whatever reason

exception raised should mention bean name in it's message to allow faster problem diagnosis


Affects: 3.1.2, 3.2 M2

1 votes, 2 watchers

@spring-projects-issues
Copy link
Collaborator Author

Piotr Findeisen commented

Rationale

When working on a bigger project, you often built application context using only a subset of XML files that exist (various application profiles, modules, test vs run-time configuration, mocks, etc.). When an exception is raised saying "No bean named 'XXX' is defined", it's not at all obvious where the problem lies.

Proposed solution

Wrap AbstractBeanFactory.doGetBean in a try-catch section that wraps exceptions in RuntimeException("Failed to get bean '<name>'")

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Juergen Hoeller I would be tempted to resolve this old issue as works as designed, but could you please have a quick look to evaluate if there is easy room for improvement or if you think our current error messages are fine?

@spring-projects-issues spring-projects-issues added type: bug A general bug status: waiting-for-triage An issue we've not yet triaged or decided on in: core Issues in core modules (aop, beans, core, context, expression) and removed type: bug A general bug labels Jan 11, 2019
@rstoyanchev rstoyanchev added status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 11, 2019
@spring-projects-issues
Copy link
Collaborator Author

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

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) status: bulk-closed An outdated, unresolved issue that's closed in bulk as part of a cleaning process
Projects
None yet
Development

No branches or pull requests

2 participants