[jboss-user] [EJB 3.0] - SessionContext injection
konstantin.ermakov
do-not-reply at jboss.com
Mon Nov 6 05:17:27 EST 2006
Hello!
I have the Entity Listener, and I want to inject a SessionContext into it:
| public class EntityBeanListener {
|
| private @Resource SessionContext context;
| ...
|
| @PostPersist
| void afterInsert(Object obj) {
| Queue q = (Queue) context.lookup("queue/MyOwnQueue");
| QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup("ConnectionFactory");
| QueueConnection cnn = factory.createQueueConnection();
| QueueSession session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
| TextMessage msg = session.createTextMessage("Inserted");
| QueueSender sender = session.createSender(q);
| sender.send(msg);
| };
|
| .....
| };
|
But the context is null, so I have the NullPointerException. Is there any workaround for this problem? In fact, the only thing that I need is to send a message to the message queue. Is there any other way to do it?
Thanks,
Konstantin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983396#3983396
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983396
More information about the jboss-user
mailing list