users@glassfish.java.net

Glassfish 3.0.1 and ActiveMQ 5.4.2 JNDI names cannot be found

From: <forums_at_java.net>
Date: Wed, 23 Mar 2011 08:16:31 -0500 (CDT)

I am using ActiveMQ as an embedded broker, I have everything setup and I'm
able to receive messages from an external client to my message driven bean.
The problem I am having is injecting resources from a session bean for the
connection factory and messge queue. Glassfish is not able to resolve the
JNDI names for those definitions in an application client. Here is my setup:
Resource Adapter Config: ServerURL = vm://localhost BrokerXmlConfig =
broker:(tcp://localhost:61616) Password = defaultPassword UseInboundSession =
false UserName = defaultUser Connector Connection Pool: PoolName =
ActiveMQMsgPool Resource Adapter = activemq-rar-5.4.2 Connection Definition =
javax.jms.ConnectionFactory Transaction Support = XATransaction Connector
Resource: JNDI Name = ActiveMQConnResource Pool Name = ActiveMQMsgPool Status
= Enabled Admin Object Resource: JNDI Name = ActiveMQ_MsgQueue Resource
Adapter = activemq-rar-5.4.2 Resource Type = javax.jms.Queue Class Name =
org.apache.activemq.command.ActiveMQQueue Status = Enabled PhysicalName =
ActiveMQ_MsgQueue JMS Resources -> Connection Factories shows my connection
pool definition in the navigation tree but not in the details list to the
right of the tree. When I click on the ActiveMQMsgPool tree item I get the
following error in the right pane of the web page. "REST Request
'http://localhost:4848/management/domain/resources/connector-resource/ActiveMQMsgPool'
failed with response code '404'" When I click on the JMS Resources ->
Destination Resources I don't see the "ActiveMQ_MsgQueue" definition of the
Admin Object Resources in the right side details list of destinations.
However I can click on the ActiveMQ_MsgQueue destination which displays with
no error however the Physical Destination Name is blank. My Message Driven
Bean uses this sun-resources.xml file: <?xml version="1.0" encoding="UTF-8"?>
My Message Driven Bean uses this sun-ejb-jar.xml file: <?xml version="1.0"
encoding="UTF-8"?>NewMessageBean NewMessageBean activemq-rar-5.4.2 And inside
my MDB I have the following annotation: @MessageDriven(mappedName =
"ActiveMQ_MsgQueue", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue =
"Auto-acknowledge"), @ActivationConfigProperty(propertyName =
"destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue =
"ActiveMQ_MsgQueue") }) The message driven bean works correctly and receives
messages from an external ActiveMQ client sending a message on the queue.
Also from a Glassfish EE application client I can send a message to the queue
and it is recieved by the MDB using the following code:
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"tcp://localhost:61616" ); // I cannot use - vm://localhost Connection
connection = connectionFactory.createConnection(); connection.start();
Session session = connection.createSession( false, Session.AUTO_ACKNOWLEDGE
); Destination destination = session.createQueue( "ActiveMQ_MsgQueue" );
MessageProducer producer = session.createProducer( destination );
producer.setDeliveryMode( DeliveryMode.PERSISTENT ); String text = "Hello
from App Client"; MapMessage message = session.createMapMessage();
message.setString( "name", text ); producer.send( message ); But what I
cannot do and what I thought I should be able to do is inject the connection
factory and queue like I can with a non-activemq (jmsra) Connection Factory
and Destination Resource. So the following code fails because Glassfish
cannot resolve the JNDI names of the connection factory and queue:
@Resource(mappedName = "ActiveMQMsgPool") private static ConnectionFactory
connectionFactory = null; @Resource(mappedName = "ActiveMQ_MsgQueue") private
static Queue queue = null; I have the following sun-resources.xml file
embedded in my App Client NetBeans project: <?xml version="1.0"
encoding="UTF-8"?> I have tried to use a sun-ejb-jar.xml with settings for
"Resource References" and "Resource Environment References" with no success.
So the question is why does are JNDI names for the ActiveMQ resources not
visible within the Glassfish container? Are there other settings within the
Admin Console that need to be setup? or are there other defintions I need to
set in the App Client NetBeans project? Thanks in advance for the help...


--
[Message sent by forum member 'v2cg4ss']
View Post: http://forums.java.net/node/784438