users@hk2.java.net

Wrong Scope Exception

From: buko <buko_at_chiubarobot.com>
Date: Thu, 15 Aug 2013 06:53:30 -0400

Encountering a strange issue. Maybe somebody else has encountered it?
Debugging through the code I see that during the lookup the narrowed
results contains this error:

[ErrorResult(SystemDescriptor(
    implementation=sourcery.client.ClientContainer$ClientImpl

contracts={sourcery.client.ClientContainer$ClientImpl,com.bubblegumproject.sourcery.client.Client}
    scope=org.glassfish.hk2.api.PerLookup
    qualifiers={}
    descriptorType=CLASS
    descriptorVisibility=NORMAL
    metadata=
    rank=0
    loader=HK2LoaderImpl(sun.misc.Launcher$AppClassLoader_at_332b9f79)
    proxiable=null
    proxyForSameScope=null
    analysisName=null
    id=7
    locatorId=0
    identityHashCode=933319313
    reified=false),null,A MultiException has 2 exceptions. They are:
1. java.lang.IllegalArgumentException: The scope name given in the
descriptor (org.glassfish.hk2.api.PerLookup) did not match the scope
annotation on the class (javax.inject.Singleton) in class
ClientContainer$ClientImpl
2. java.lang.IllegalArgumentException: Errors were discovered while
reifying SystemDescriptor(
    implementation=sourcery.client.ClientContainer$ClientImpl

contracts={sourcery.client.ClientContainer$ClientImpl,com.bubblegumproject.sourcery.client.Client}
    scope=org.glassfish.hk2.api.PerLookup
    qualifiers={}
    descriptorType=CLASS
    descriptorVisibility=NORMAL
    metadata=
    rank=0
    loader=HK2LoaderImpl(sun.misc.Launcher$AppClassLoader_at_332b9f79)
    proxiable=null
    proxyForSameScope=null
    analysisName=null
    id=7
    locatorId=0
    identityHashCode=933319313
    reified=false)
,465001913)]

Two problems: (1) the ClientImpl class doesn't have the @Singleton
annotation and (2) for some reason, errorHandlers is empty and so this
error is silently suppressed. No exception is raised. I only found it by
stepping through the code.

Adding the @Singleton annotation makes everything better.

Any ideas?