You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Alexander Falb (JIRA)" <ji...@apache.org> on 2017/03/09 15:42:38 UTC

[jira] [Created] (TOMEE-2020) NPE in OpenEJBLifecycle when voting against beans

Alexander Falb created TOMEE-2020:
-------------------------------------

             Summary: NPE in OpenEJBLifecycle when voting against beans
                 Key: TOMEE-2020
                 URL: https://issues.apache.org/jira/browse/TOMEE-2020
             Project: TomEE
          Issue Type: Bug
    Affects Versions: 7.0.2
            Reporter: Alexander Falb
         Attachments: openejb-trace.log

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:
{code}
@javax.ejb.Startup
@javax.ejb.Singleton
@Exclude(ifProjectStage = {Development.UnitTest.class})
public class MySingletonEJB { [...] }
{code}

The CDI extension just does some evaluation based on the parameters in {{@Exclude}} and calls {{processAnnotatedType.veto()}} like
{code}
vetoBeans(@Observes ProcessAnnotatedType pat) {
    if ([...]) pat.veto();
}
{code}

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.
{code}
// 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())) {
        [...]
{code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)