4 Replies Latest reply on Feb 11, 2013 10:10 AM by Mathieu Lachance

    producer.produce(ctx) issue in weld 2.0.0.Beta3

    Mathieu Lachance Novice

      Hello everyone,

       

      I'm migrating from Weld SE 1.1.9.Final to Weld SE 2.0.0.Beta3 and I'm having issue to invoke producer method with unbounded creational context.

      The following piece of code that was working fine in the 1.1.9.Final version :

       

       

          public <T, X> void onProcessProducer(@Observes ProcessProducer<T, Configuration> event, BeanManager beanManager)
          {
              CacheName cacheName = event.getAnnotatedMember().getAnnotation(CacheName.class);
              if (cacheName == null)
              {
                  throw new NullPointerException("@CacheName must be defined");
              }
              CreationalContext<Configuration> ctx = beanManager.createCreationalContext(null);
              Configuration cacheConfiguration = event.getProducer().produce(ctx);
              configurations.put(cacheName.value(), cacheConfiguration);
          }
      
      

       

      but I get the following stack trace in the 2.0.0.Beta3 version :

       

      org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
      Exception 0 :
      org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456 Argument bean must not be null
                at org.jboss.weld.util.Preconditions.checkArgumentNotNull(Preconditions.java:40)
                at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:715)
                at org.jboss.weld.bean.ManagedBean.getUnboundRequestContext(ManagedBean.java:272)
                at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:167)
                at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)
                at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:699)
                at org.jboss.weld.injection.producer.AbstractMemberProducer.getReceiver(AbstractMemberProducer.java:116)
                at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:185)
                at XXX.core.cache.InfinispanExtension.onProcessProducer(InfinispanExtension.java:43)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:601)
                at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:268)
                at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
                at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
                at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:264)
                at org.jboss.weld.annotated.runtime.InvokableAnnotatedMethod.invokeOnInstance(InvokableAnnotatedMethod.java:82)
                at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:97)
                at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:273)
                at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:129)
                at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:260)
                at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:239)
                at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:155)
                at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:116)
                at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:101)
                at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:69)
                at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:38)
                at org.jboss.weld.bootstrap.events.ProcessProducerImpl.fire(ProcessProducerImpl.java:34)
                at org.jboss.weld.bootstrap.events.ContainerLifecycleEvents.fireProcessProducer(ContainerLifecycleEvents.java:211)
                at org.jboss.weld.bootstrap.AbstractBeanDeployer.fireBeanEvents(AbstractBeanDeployer.java:141)
                at org.jboss.weld.bootstrap.AbstractBeanDeployer.fireBeanEvents(AbstractBeanDeployer.java:133)
                at org.jboss.weld.bootstrap.BeanDeployer.deploy(BeanDeployer.java:313)
                at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:267)
                at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:462)
                at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:70)
                at org.jboss.weld.environment.se.Weld.initialize(Weld.java:137)
                at XXX.integration.WeldRunner.initializeWeld(WeldRunner.java:35)
                at XXX.integration.WeldRunner.run(WeldRunner.java:20)
                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      
                at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:40)
                at org.jboss.weld.bootstrap.events.ProcessProducerImpl.fire(ProcessProducerImpl.java:34)
                at org.jboss.weld.bootstrap.events.ContainerLifecycleEvents.fireProcessProducer(ContainerLifecycleEvents.java:211)
                at org.jboss.weld.bootstrap.AbstractBeanDeployer.fireBeanEvents(AbstractBeanDeployer.java:141)
                at org.jboss.weld.bootstrap.AbstractBeanDeployer.fireBeanEvents(AbstractBeanDeployer.java:133)
                at org.jboss.weld.bootstrap.BeanDeployer.deploy(BeanDeployer.java:313)
                at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:267)
                at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:462)
                at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:70)
                at org.jboss.weld.environment.se.Weld.initialize(Weld.java:137)
                at XXX.integration.WeldRunner.initializeWeld(WeldRunner.java:35)
                at XXX.integration.WeldRunner.run(WeldRunner.java:20)
                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      
      

       

      Any ideas how I could migrate my code to make this work again ?

       

      Thanks,