-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Misleading error message when no constructor or factory method can be found #29052
Comments
Thanks for the report and for trying out our snapshots. I don't recall seeing this problem before. It would appear that @CynanX, if you're unable to reproduce the problem in a minimal sample it would be interesting to know more about the bean for which the register method cannot be generated. Could you debug your failing application and identify the |
After a lot of trial & error I've managed to get to the bottom of this, and it was caused by one class in my application. This particular class has a combination of field and constructor autowired Spring beans, along with a second constructor used by a test class which could override them all. I've not got time right now, so here is a knocked up example. I'll get a working sample put together later and provide a link if required. E.g. code scenario: - @Component("SampleClass")
@Scope("prototype")
public class SampleClass {
private final BeanA beanA;
private final BeanB beanB;
@Autowired
private BeanC beanC;
public SampleClass(BeanA beanA, BeanB beanB) {
this.beanA = beanA;
this.beanB = beanB;
}
@VisibleForTesting
protected SampleClass(BeanA beanA, BeanB beanB, BeanC beanC) {
this.beanA = beanA;
this.beanB = beanB;
this.beanC = beanC;
}
} Once I commented out the second constructor the application built as expected. I totally get this is bad code, and I'm not expecting any fixes for it (that said non-native does work with it). However if the error message could indicate the class with the issue in that would be nice. |
Sample application created here. |
I'm interested in contributing to this issue, would you mind sparing your time explaining what the fix would exactly be and pointing me to some resources to get started. |
@CynanX thanks for the sample. @sreenath-tm thanks for the offer but this one is a little tricky and I am afraid I won't be able to provide direction until I get to the bottom of it. This might be a duplicate of #27920 |
@CynanX this fix the error message, not the underlying issue of resolving the constructor. As I was suspecting, the proper fix will happen once we work on #27920. The exception on your sample is now:
|
Thanks @snicoll ! |
I have a fairly complex application that I've been testing with SB3 milestones, and now snapshots.
It builds and runs fine, except when I switch on the native profile.
As the application is quite large it's quite difficult to try and isolate which part is causing this.
I will keep trying to find the issue however and report back.
I thought it best to raise this as soon as however so you guys are aware, and perhaps you have already seen this issue? I could not find an existing issue raised for it however.
I'm running this with:
The text was updated successfully, but these errors were encountered: