I'm having problems looking up connection factories via JNDI, from a
standalone Java client when ActiveMQ is integrated with JBoss using a RAR.
Whilst something appears bound in JNDI - I don't get a NamingException -
I get a null object reference back, looking up topics and queues works fine.

I've followed the instructions on
http://devzone.logicblaze.com/site/integrating-apache-activemq-with-jboss.html
for integrating ActiveMQ with JBoss using both the RAR files supplied on
that page for ActiveMQ 4.0.2 and also putting together my own RAR with
ActiveMQ 4.1, both with the same result.

I'm using the following as my activemq-jms-ds.xml file, including using the
<use-java-context>false</use-java-context> so that the connection factories
appear in the global JNDI space rather than under java: 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE connection-factories
    PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd";>

<connection-factories>

   <tx-connection-factory>
      <jndi-name>testing/QueueConnectionFactory</jndi-name>
          <!-- By default the connection factory will be bound to the java:
context, setting this to false
                  puts it into the global JNDI-->
          <use-java-context>false</use-java-context> 
      <xa-transaction/>
      <track-connection-by-tx/>
      <rar-name>activemq-ra.rar</rar-name>
     
<connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
      <ServerUrl>vm://localhost</ServerUrl>
      <!--
      <UserName>sa</UserName>
      <Password></Password>
      -->
      <min-pool-size>1</min-pool-size>
      <max-pool-size>200</max-pool-size>
      <blocking-timeout-millis>30000</blocking-timeout-millis>
      <idle-timeout-minutes>3</idle-timeout-minutes>
   </tx-connection-factory>

   <tx-connection-factory>
      <jndi-name>testing/TopicConnectionFactory</jndi-name>
          <!-- By default the connection factory will be bound to the java:
context, setting this to false
                  puts it into the global JNDI-->
          <use-java-context>false</use-java-context>       
      <xa-transaction/>
      <track-connection-by-tx/>
      <rar-name>activemq-ra.rar</rar-name>
     
<connection-definition>javax.jms.TopicConnectionFactory</connection-definition>
      <ServerUrl>vm://localhost</ServerUrl>
      <!--
      <UserName>sa</UserName>
      <Password></Password>
      -->
      <min-pool-size>1</min-pool-size>
      <max-pool-size>200</max-pool-size>
      <blocking-timeout-millis>30000</blocking-timeout-millis>
      <idle-timeout-minutes>3</idle-timeout-minutes>
   </tx-connection-factory>
   
   <mbean code="org.jboss.resource.deployment.AdminObject"
name="activemq.queue:name=ossjRequestQueue">
      <attribute name="JNDIName">testing/MessageQueue</attribute>
      <depends
optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
      <attribute name="Type">javax.jms.Queue</attribute>
      <attribute
name="Properties">PhysicalName=queue.ossjRequestQueue</attribute>
   </mbean>

   <mbean code="org.jboss.resource.deployment.AdminObject"
name="activemq.topic:name=ossjXmlEventTopic">
      <attribute name="JNDIName">testing/XVTEventTopic</attribute>
      <depends
optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
      <attribute name="Type">javax.jms.Topic</attribute>
      <attribute
name="Properties">PhysicalName=topic.ossjXmlEventTopic</attribute>
   </mbean>
        
   <mbean code="org.jboss.resource.deployment.AdminObject"
name="activemq.topic:name=ossjJavaEventTopic">
      <attribute name="JNDIName">testing/JVTEventTopic</attribute>
      <depends
optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
      <attribute name="Type">javax.jms.Topic</attribute>
      <attribute
name="Properties">PhysicalName=topic.ossjJavaEventTopic</attribute>
   </mbean>     

</connection-factories>

When JBoss starts up I see:

01:12:08,714 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager
'jboss.jca:service=ConnectionFactoryBinding,name=testing/QueueConnectionFactory'
to JNDI name 'testing/QueueConnectionFactory'
01:12:08,726 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager
'jboss.jca:service=ConnectionFactoryBinding,name=testing/TopicConnectionFactory'
to JNDI name 'testing/TopicConnectionFactory'
01:12:08,738 INFO  [AdminObject] Bound admin object
'org.apache.activemq.command.ActiveMQQueue' at 'testing/MessageQueue'
01:12:08,743 INFO  [AdminObject] Bound admin object
'org.apache.activemq.command.ActiveMQTopic' at 'testing/XVTEventTopic'
01:12:08,747 INFO  [AdminObject] Bound admin object
'org.apache.activemq.command.ActiveMQTopic' at 'testing/JVTEventTopic'

The following piece of code prints out:
null
Is null!!

        System.out.println("Looking up topic factory");
        try {
            ref = jndiContext.lookup("testing/TopicConnectionFactory");
            System.out.println(ref);
            if (ref == null) {
                System.out.println("Is null!!");
            }
            TopicConnectionFactory tFactory = (TopicConnectionFactory)
PortableRemoteObject
                    .narrow(ref, TopicConnectionFactory.class);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }

But listing everything under "testing" I get
Name: JVTEventTopic , Class: org.apache.activemq.command.ActiveMQTopic
Name: QueueConnectionFactory , Class:
org.apache.activemq.ra.ActiveMQConnectionFactory
Name: TopicConnectionFactory , Class:
org.apache.activemq.ra.ActiveMQConnectionFactory
Name: MessageQueue , Class: org.apache.activemq.command.ActiveMQQueue
Name: XVTEventTopic , Class: org.apache.activemq.command.ActiveMQTopic

with the following piece of code:

        NamingEnumeration<NameClassPair> namingEnum =
jndiContext.list("testing");
        while (namingEnum.hasMore()) {
            NameClassPair nameClassPair = namingEnum.next();
            System.out.println("Name: " + nameClassPair.getName() + " ,
Class: " + nameClassPair.getClassName() );
        }

I'm using JBoss 4.0.5  running with a JRE 1.5.0_05-b05

What have I got wrong/am I missing?

Thanks,

Paul
-- 
View this message in context: 
http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463.html#a8513200
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to