[jboss-user] [EJB 3.0] - Injection of QueueConnectionFactory and Queue from ENC in ap
Wolfgang Knauf
do-not-reply at jboss.com
Mon Jan 26 16:49:32 EST 2009
Hi all,
I try to use the @Resource annotation to inject a QueueConnectionFactory and a Queue (to a MDB) in an EJB3 application client.
I run into strange problems which I cannot explain, but got it finally working.
For injecting the QueueConnectionFactory, I could use an ENC entry:
@Resource(name="jms/MBConnectionFactory")
| //This is the global JNDI name (works fine)
| //@Resource(mappedName="ConnectionFactory")
| private static QueueConnectionFactory queueConnectionFactory;
(the commented line of code injects the factory from global JNDI, and this works also).
But for the Queue, the ENC could not be used (results in "...not bound" exceptions). Here, I was forced to use the global name:
@Resource(mappedName="queue/MessageBeanQueue")
| //Using the ENC Does NOT work!
| //@Resource(name="jms/MBQueueRef")
| //@Resource(mappedName="jms/MBQueueRef")
| private static Queue queue;
application-client.xml and jboss-client.xml define the resource references. Here is "jboss-client.xml":
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE jboss-client PUBLIC
| "-//JBoss//DTD Application Client 5.0//EN"
| "http://www.jboss.org/j2ee/dtd/jboss-client_5_0.dtd">
| <jboss-client>
| <jndi-name>MessageClient</jndi-name>
| <resource-ref>
| <res-ref-name>jms/MBConnectionFactory</res-ref-name>
| <jndi-name>ConnectionFactory</jndi-name>
| </resource-ref>
| <resource-ref>
| <res-ref-name>jms/MBQueueRef</res-ref-name>
| <jndi-name>queue/MessageBeanQueue</jndi-name>
| </resource-ref>
| </jboss-client>
Lookup through InitialContext works fine, so the ENC is valid.
Am I doing something wrong? Is there an injection bug (ENC works for the QueueConnectionFactory, but not for the Queue)?
My sample can be found here:
http://www.informatik.fh-wiesbaden.de/~knauf/private/mdb/injection/
(it differs from the one of my post http://www.jboss.com/index.html?module=bb&op=viewtopic&t=149328, so all four files are required)
Thanks
Wolfgang
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204839#4204839
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204839
More information about the jboss-user
mailing list