0 Replies Latest reply on Sep 26, 2012 9:18 AM by Marco Piraccini

    @Singleton with @Startup do not deploy (NPE) if CDI is used

    Marco Piraccini Newbie

      Hi guys,

       

      I have already filled a Jira (https://issues.jboss.org/browse/JBAS-9517), but now I'm looking for a workaround for that issue.

       

      That happens with JBoss 6.1.Final (with JBoss 6.0.0 the behaviour is correct). 

       

      If a bean is annotated with @Singleton and @Startup and CDI is used this NPE is thrown:

      Caused by: java.lang.NullPointerException
      at org.jboss.weld.integration.instantiator.Jsr299BeanInstantiator.create(Jsr299BeanInstantiator.java:74) [:6.1.0.Final]
      at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:1048) [:1.7.21]
      at org.jboss.ejb3.stateless.StatelessContainer.createBeanContext(StatelessContainer.java:123) [:1.7.21]
      at org.jboss.ejb3.pool.AbstractPool.createBeanContext(AbstractPool.java:94) [:1.7.21]
      at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:81) [:1.7.21]
      at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:62) [:1.7.21]
      at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:57) [:1.7.21]
      at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:54) [:1.7.21]
      at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:86) [:1.7.21]
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:58) [:1.7.21]
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.2.GA]
      at org.jboss.ejb3.core.context.SessionInvocationContextAdapter.proceed(SessionInvocationContextAdapter.java:95) [:1.7.21]
      at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:223) [:0.0.2]
      ... 99 more

      This happens in this cases:

      • CDI activated (e.g. beans.xml present in the bean's jar. Removing the beans.xml it deploys).
      • If the singleton refers to other beans in other jars (injected with @EJB) which in turn use CDI.

         Removing @Startup, the deploy works.

       

      Any workaround for that?