I have a project using Jersey 2.25 (with HK2 2.5-b30). Originally, I was using the HK2-Guice Bridge. However, this seems to fail unexpectedly for some cases (in particular, cases where Strings are annotated with a custom annotation configured in Guice will work fine when Guice is doing the injection, but fail silently when HK2 is doing it). Because the same object can act differently depending on how it's injected, I'm becoming terrified of using both together.
I'm now switching everything to use HK2, but sadly it seems like HK2 fails for certain cases where Guice would succeed. In particular, it seems HK2 does not like injecting where a type was not explicitly configured. Guice was happy to just create a new instance of these classes and inject recursively, but HK2 not so much. For example,
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=TimeRangeRequestValidator,parent=GetWatchlistEventsImpl,qualifiers={},position=-1,optional=false,self=false,unqualified=null,1218743359)
As you can see, the error message isn't very helpful at all. It should be able to create a TimeRangeRequestValidator
, which references some other objects, all of which Guice was able to create with no problem. Is there some list of different behaviors between HK2 and Guice so I can track down why this isn't working?
Note that TimeRangeRequestValidator
is a class (not an interface) annotated with @Singleton
that has a default public constructor and a field annotated with Inject
. Guice had no problems instantiating it.