Improve exception when failing to create a specific bean due to a NoClassDefFoundError [SPR-14883] #19449
I am currently stuck in determining the cause of a NoClassDefFoundError that is occurring in my project.
I am reporting this ticket to request an improvement, and to discuss how it should be implemented.
My specific problem (which I can't diagnose on my own) is a NoClassDefFoundError
From my understanding, some bean contains an
Now the problem is that this stack trace does not provide information on what bean caused the failure. I could get more information if I had either the name of the bean that contains the faulty
My proposal is for Spring Framework to increase the number of catch(Throwable) statements, and log little extra contextual information when these Throwables occur.
A simple, but probably insufficient and too simplicistic, proposal for which I could create a PR easily, is to wrap the entire doGetBean method in the following:
Another alternate proposal, that follows a pattern I like a lot to apply, is the following (DefaultListableBeanFactory#731):
The pattern is: when performing a loop, identify the element that caused an exception and throw its identifying information in a new exception that wraps the cause. This helps diagnosis.
This is meant to provide discussion and improvement. I will have to debug my specific error on my own, but I would like to see this (especially the second pattern) implemented in future releases
The text was updated successfully, but these errors were encountered:
Juergen Hoeller commented
I've tackled this from two angles:
The former change will make it into the 4.3.4 release, for immediate availability tomorrow. The latter will only make it into 5.0 M3 since there are some subtle side effects to be expected.
As for generally catching exceptions on iteration, that's a fine point but for bean lookup/creation specifically I'd prefer the guards in the