dev@jersey.java.net

Difficulties getting the new CDI impl to work with the sample

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 12 Aug 2010 14:39:46 +0200

Hi Roberto,

I am getting some odd errors when deploying the CDI sample (i needed
to modify it to add a beans.xml) with the latest version of Jersey
copied into GlassFish promoted build 15.

When i deploy i am getting an NPE in the CDIExtension class at:

     void lateInitialize() {
         // NPE here because toBeInitializedLater is null
         for (InitializedLater object : toBeInitializedLater) {
             object.later();
         }
     }

I verified that the CDIExtension appears to be behaving as required
via the log messages i.e. the before bean discovery event occurs:

     void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
         initialize();

         // turn JAX-RS injection annotations into CDI qualifiers
         for (Class<? extends Annotation> qualifier :
knownParameterQualifiers) {
             event.addQualifier(qualifier);
         }
     }

I also verified that the value of the CDIExtension.toString is the
same for the instance that is created and the instance that is looked
up using the BeanManager:

     public void onWebApplicationReady() {
         CDIExtension extension = Utils.getInstance(beanManager,
CDIExtension.class);

         extension.lateInitialize();
     }


However the concrete class is of CDIExtension of the reference that is
looked up via BeanManager is:

   class com.sun.jersey.server.impl.cdi.CDIExtension_$$_WeldProxy

I suspect that weld proxying is not working correctly and the method
calls on the proxy reference are not being correctly delegated to the
proxied instance.

I will try the latest nightly build.

Paul.