Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
7.0.2
-
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())) { [...]