Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-2020

NPE in OpenEJBLifecycle when voting against beans

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.0.2
    • 7.0.4
    • None
    • None

    Description

      We have some EJBs in our application which we disable during development by voting against them with a CDI extension.

      When we upgraded from JavaEE6 (OpenEJB 4.7.4) to JavaEE7 (OpenEJB 7.0.2) we encountered NullPointerExceptions in OpenEJBLifecycle:265 (see attached openejb-trace.log).

      Our EJBs look like this:

      @javax.ejb.Startup
      @javax.ejb.Singleton
      @Exclude(ifProjectStage = {Development.UnitTest.class})
      public class MySingletonEJB { [...] }
      

      The CDI extension just does some evaluation based on the parameters in @Exclude and calls processAnnotatedType.veto() like

      vetoBeans(@Observes ProcessAnnotatedType pat) {
          if ([...]) pat.veto();
      }
      

      I debugged OpenEJBLifecycle a bit and it looks like the beanManager does not "know" the bean (because it got vetoed), but OpenEJB assumes to get a bean reference from it. The NPE happens when calling bean.getScope(), because bean is null.

      // OpenEJBLifecycle:263-265
      private void starts(final BeanManager beanManager, final Class<?> clazz) {
          final Bean<?> bean = beanManager.resolve(beanManager.getBeans(clazz));
          if (!beanManager.isNormalScope(bean.getScope())) {
              [...]
      

      Attachments

        1. openejb-trace.log
          3 kB
          Alexander Falb

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            elexx Alexander Falb
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: