1

I have a Singleton bean, and I have a Stateful bean too. I need to use the Singleton bean in the testclass of my Stateful bean. If I simply just inject it:

@Inject
private MySingletonBean mySingletonBean;

I got null instead of the Stateful bean. Any ideas, why is it, how to fix it?

Display Name
  • 1,121
  • 2
  • 11
  • 14

1 Answers1

0

Could be many reasons. It can happen if the stateful bean was manually instantiated like

new StatefulBean()

If MySingletonBean is in a jar that doesn't have a META-INF/beans.xml file, it will also not be used for injection. Is this a JEE application? Do you get in messages in the log when the application is started? There might be hints about what's going wrong ifit's not one of the reasons mentioned above.

Guenther
  • 2,035
  • 2
  • 15
  • 20