jersey
  1. jersey
  2. JERSEY-2393

GLassfish failed to inject CDI managed beans in an ExceptionMapper

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: containers
    • Labels:
      None
    • Environment:

      Glassfish 4

      Description

      I created a custom ExceptionMapper and I want to inject a CDI managed bean (singleton) into it

      @Provider
      public class MyExceptionMapper implements ExceptionMapper<Throwable> {
      @Inject
      private Manager myManager;

      @Override
      public Response toResponse(Throwable exception)

      { // My implementation }

      }

      I get the following exception when I access the application
      org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=Manager,parent=MyExceptionMapper,qu
      alifiers={}),position=-1,optional=false,self=false,unqualified=null,1954647854)
      at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:74)
      at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:191)
      at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:214)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:311)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
      at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2204)
      at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
      at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:57)
      at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:53)
      at com.google.common.collect.Iterators$8.transform(Iterators.java:860)
      at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
      at java.util.AbstractCollection.addAll(AbstractCollection.java:341)
      at java.util.LinkedHashSet.<init>(LinkedHashSet.java:169)
      at com.google.common.collect.Sets.newLinkedHashSet(Sets.java:292)
      at org.glassfish.jersey.internal.inject.Providers.getClasses(Providers.java:336)
      at org.glassfish.jersey.internal.inject.Providers.getAllProviders(Providers.java:323)
      at org.glassfish.jersey.internal.inject.Providers.getAllProviders(Providers.java:213)
      at org.glassfish.jersey.internal.ExceptionMapperFactory.<init>(ExceptionMapperFactory.java:158)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1091)
      at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:244)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:319)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)

        Issue Links

          Activity

          Hide
          Jakub Podlesak added a comment -

          Please feel free to re-open after updating the test case.

          Show
          Jakub Podlesak added a comment - Please feel free to re-open after updating the test case.
          Hide
          hazem added a comment -

          The test case is updated

          Show
          hazem added a comment - The test case is updated
          Hide
          hazem added a comment -

          I do not have permission to re-open this bug

          Show
          hazem added a comment - I do not have permission to re-open this bug
          Hide
          Jakub Podlesak added a comment -

          Re-opening so that the reporter has a chance to either: confirm the updated test case works for him or to clarify, why the update does not work for him.
          Going to close this one as invalid if i do not hear any news as myself and one other user confirmed suggested test case update works just fine.

          Show
          Jakub Podlesak added a comment - Re-opening so that the reporter has a chance to either: confirm the updated test case works for him or to clarify, why the update does not work for him. Going to close this one as invalid if i do not hear any news as myself and one other user confirmed suggested test case update works just fine.
          Hide
          hazem added a comment -

          The suggested solution works on glassfish 4.0.1 but does not work on glassfish 4.0

          Show
          hazem added a comment - The suggested solution works on glassfish 4.0.1 but does not work on glassfish 4.0

            People

            • Assignee:
              Jakub Podlesak
              Reporter:
              hazem
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: