1
votes

I was spending a lot time to sort out problem with JBoss 6.1.0 to inject JMS connection factory in my session bean. I am using JBoss 6.1.0 with default profile and running it in debian.

Snip of my code are:

@Resource(name="java:/QueueConnectionFactory")
private QueueConnectionFactory factory

There is in jboss6/server/default/deploy/hornetq/hornetq-jms.xml:

<connection-factory name="QueueConnectionFactory" signature="queue">
        <xa>true</xa>
        <connectors>
           <connector-ref connector-name="in-vm"/>
        </connectors>
        <entries>
            <entry name="java:/QueueConnectionFactory"/>           
        </entries>
    </connection-factory>

While deploying my ear-file I am getting this error:

Neither any mapped-name/lookup/jndi-name specified nor any ResourceProvider could process resource-ref named env/java:/QueueConnectionFactory of type javax.jms.QueueConnectionFactory

It can't inject queue connection factory in my session bean despite of the queue factory being visible in the admin console.

2

2 Answers

2
votes

Finally I have found the answer to my question:

In the @Resource annotation the mappedName attribute with the real JNDI resource name is required as well.

0
votes

Here is a simple MDB that can produce a JMS and it works in JBoss 6.1.0

Working code here : https://github.com/OpenRAP/jboss6-jms-chat

@MessageDriven(activationConfig = {
@ActivationConfigProperty(
        propertyName = "destinationType",
        propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(
        propertyName = "destination",
        propertyValue = "queue/questionqueue"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "durable")})
public class ChatBean implements MessageListener {

@Resource(mappedName = "java:/JmsXA")
private ConnectionFactory queueConnectionFactory;

@Resource(mappedName = "queue/answerqueue")
private Queue answerQueue;

public void onMessage(Message message) {}
}