nicholas
nicholas

Reputation: 2772

Java Bean CDI Null Pointer Exception

I have a normal java bean which is singleton with jms resource like this :

@Resource(lookup="jms/queueConnectionFactory")
  private QueueConnectionFactory myQueueConnFactory;

  @Resource(lookup="jms/myQueue")
  private Queue myMessageQueue;

  private Connection myConn;
  private Session mySession;

  private MessageProducer msgProducer;
  private MapMessage myMsg;

  @PersistenceContext(name="OrderServicePU")
  EntityManager em;

  private static MyProducer msgClientProducer;

I tried to inject it to servlet controller but resulted with null pointer exception where the queue and connection factory is not get initialized.

@Inject private MyProducer msgProducer;

I have beans.xml and glassfish-resources.xml defined.

What wrong with that ?

Upvotes: 0

Views: 472

Answers (1)

nicholas
nicholas

Reputation: 2772

The problem solved by properly configure the JMS resource.

Upvotes: 0

Related Questions