You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 28, 2018. It is now read-only.
java.lang.NoSuchMethodException: Could not find a suitable constructor in com.mycompany.jersey2guice.JerseyApplication class.
at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:189)
[...]
Expected behavior: explain what constitutes a "suitable constructor" in the exception message so developers know what needs to get fixed. Either link to a more detailed explanation or describe it inline.
Also, it would be useful if you provided more contextual information, such as "Found constructors X, Y, Z. Was looking for A, B or C"
Affected Versions
[2.2]
The text was updated successfully, but these errors were encountered:
It looks like the error messages are coming from hk2 so you might have to redirect this bug report there.
Please pay special attention to constructors annotated with @Inject. It is a common mistake to import com.google.Inject instead of javax.inject.Inject. Currently, org.jvnet.hk2.internal.Utilities.hasInjectAnnotation() checks for javax.inject.Inject and throws an error if two constructors are annotated with @Inject. I suggest throwing an error if a constructor is annotated with @Inject that does not resolve to javax.inject.Inject in order to help users catch errors. As far as I know, each class only uses one type of @Inject at a time so we are unlikely to run into false positives.
In my case the constructor in my resource/controller required some arguments, I removed them and now everything works. I guess Jersey's reflection can't initialize the class if there are some arguments, because obviously it doesn't know what to put there. This wasn't clear at a first look.
Jersey throws the following exception:
Expected behavior: explain what constitutes a "suitable constructor" in the exception message so developers know what needs to get fixed. Either link to a more detailed explanation or describe it inline.
Also, it would be useful if you provided more contextual information, such as "Found constructors X, Y, Z. Was looking for A, B or C"
Affected Versions
[2.2]
The text was updated successfully, but these errors were encountered: