On 09.03.2016 21:53, Laird Nelson wrote:
> On Wed, Mar 9, 2016 at 7:04 AM ax487 <ax487_at_gmx.de> wrote:
>
>> No, not exactly, unfortunately. Simply calling "register" does not seem
>> to "bind" the registered instance to be usable for injection.
>>
>
> Making a bit of a leap here, but perhaps what you are saying is that your
> singleton implements some interface that you want to use as the type for
> various injection slots, and injection at those points is failing.
> Further, I'm going to guess that the interfaces in question are not
> annotated with HK2's Contract annotation.
>
> If that's what's going on, you probably want this variant of the register()
> method:
> https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/server/ResourceConfig.html#register(java.lang.Object,%20java.lang.Class...)
> Then you can specify exactly what contract types should be used. Good
> luck.
>
> Best,
> Laird
>
Well, I tried that. I don't really have contracts (interfaces) though.
So I tried using `register(new SingletonExample(args),
SingletonExample.class)`. But I just get an exception when I try to
instanciated a resource:
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no
object available for injection at
SystemInjecteeImpl(requiredType=SingletonExample,parent=ResourceExample,qualifiers={},position=0,optional=false,self=false,unqualified=null,555676986)