You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Paul Moser <ap...@paulmoser.co.uk> on 2007/01/23 01:32:04 UTC

JBoss integration and lookup of connection factories.

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.


Re: JBoss integration and lookup of connection factories.

Posted by James Strachan <ja...@gmail.com>.
On 4/10/07, wallace <wa...@yahoo.com> wrote:
>
> Thanks for response.
>
> This works for me too. But it is a very big limitation to require the client
> to hard code the physical queue name (in your example, example.MyQueue). It
> defeats the purpose of jndi.

The properties file can be put in the jndi.properties on the classpath
as mentioned in the documentation; so there's no need to use the
actual physical queue names in your Java code if you want.

http://activemq.apache.org/jndi-support.html

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: JBoss integration and lookup of connection factories.

Posted by wallace <wa...@yahoo.com>.
Thanks for response.

This works for me too. But it is a very big limitation to require the client
to hard code the physical queue name (in your example, example.MyQueue). It
defeats the purpose of jndi.  The client should only need to know the jndi
name. So no code change is necessary when the server change the physical
name.

It is now a funny situation. If I lookup from activemq jndi, I have to pass
in the physical name. I can actually lookup the topic name from jboss jndi.
But if I lookup from jboss jndi, connection factory will return null (It
looks like a bug to me as context list binding returns the correct class
name).  Neither of the jndi server gets me both things right.

Thanks for your help though.
-Wallace


rachit goel wrote:
> 
> @ WALLACE
> 
> Yes i have successfully implemented the jms thing rom core java 
> application. 
> 
> if u use 
> 
>                 Properties	Initialcontext_props = null;
> 		
> 		queueName = "example.MyQueue";
> 		
> 		Initialcontext_props = new Properties();
> 		Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> 		Initialcontext_props.put(Context.PROVIDER_URL, "tcp://app-minim:61616");
> 	
> Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
> 		Initialcontext_props.put("queue.MyQueue" , queueName);
> 
> 	       jndiContext = new InitialContext(Initialcontext_props);
> 
> 
> it will work just fine . Also make sure u have addedd the active-mq's jar
> file in ur classpath.
> 
> 
> 
> wallace wrote:
>> 
>> I can make the jndi lookup working within jboss j2ee container. But jndi
>> apparently does not work from a single standalone client, when accessing
>> jndi of jboss.
>> 
>> For example,
>>            Properties env2 = new Properties();
>>            ......
>>            env2.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>>            env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>            InitialContext jndi2 = new InitialContext(env2);          
>>            
>>            TopicConnectionFactory connectionFactory =
>> (javax.jms.TopicConnectionFactory)
>> jndi2.lookup("java:activemq/TopicConnectionFactory");
>>            
>> The code always returns name not found exception. Has anyone ever made it
>> work in standalone client?
>> 
>> -Wallace Wong
>> 
>> 
>> 
>> tbaker73 wrote:
>>> 
>>> James, could you please provide an example of the connection factory
>>> entry to add under <connection-factories> in a -ds.xml file that would
>>> accomplish what you suggest? How would it differ from this entry?
>>>    <tx-connection-factory>
>>>       <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>>       <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>
>>> 
>>> 
>>> James.Strachan wrote:
>>>> 
>>>> 
>>>> You'll need to setup a regular JMS connection and any destination
>>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>>> well work fine though - just make sure its actually normal JMS client
>>>> objects (ConnectionFactory & destinations) - and not RA stuff.  Also
>>>> make sure the J2EE server and your stand alone client are using the
>>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>>> to transmit the Java objects in JNDI
>>>> -- 
>>>> 
>>>> James
>>>> -------
>>>> http://radio.weblogs.com/0112098/
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

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


Re: JBoss integration and lookup of connection factories.

Posted by rachit goel <pa...@yahoo.co.uk>.
well u can get them from user at run time . like ome sort of preferences or
key - value pair properties file.



wallace wrote:
> 
> Thanks for response.
> 
> This works for me too. But it is a very big limitation to require the
> client to hard code the physical queue name (in your example,
> example.MyQueue). It defeats the purpose of jndi.  The client should only
> need to know the jndi name. So no code change is necessary when the server
> change the physical name.
> 
> It is now a funny situation. If I lookup from activemq jndi, I have to
> pass in the physical name. I can actually lookup the topic name from jboss
> jndi. But if I lookup from jboss jndi, connection factory will return null
> (It looks like a bug to me as context list binding returns the correct
> class name).  Neither of the jndi server gets me both things right.
> 
> Thanks for your help though.
> -Wallace
> 
> 
> rachit goel wrote:
>> 
>> @ WALLACE
>> 
>> Yes i have successfully implemented the jms thing rom core java 
>> application. 
>> 
>> if u use 
>> 
>>                 Properties	Initialcontext_props = null;
>> 		
>> 		queueName = "example.MyQueue";
>> 		
>> 		Initialcontext_props = new Properties();
>> 		Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
>> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
>> 		Initialcontext_props.put(Context.PROVIDER_URL,
>> "tcp://app-minim:61616");
>> 	
>> Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
>> 		Initialcontext_props.put("queue.MyQueue" , queueName);
>> 
>> 	       jndiContext = new InitialContext(Initialcontext_props);
>> 
>> 
>> it will work just fine . Also make sure u have addedd the active-mq's jar
>> file in ur classpath.
>> 
>> 
>> 
>> wallace wrote:
>>> 
>>> I can make the jndi lookup working within jboss j2ee container. But jndi
>>> apparently does not work from a single standalone client, when accessing
>>> jndi of jboss.
>>> 
>>> For example,
>>>            Properties env2 = new Properties();
>>>            ......
>>>            env2.put(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.jnp.interfaces.NamingContextFactory");
>>>            env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>>            InitialContext jndi2 = new InitialContext(env2);          
>>>            
>>>            TopicConnectionFactory connectionFactory =
>>> (javax.jms.TopicConnectionFactory)
>>> jndi2.lookup("java:activemq/TopicConnectionFactory");
>>>            
>>> The code always returns name not found exception. Has anyone ever made
>>> it work in standalone client?
>>> 
>>> -Wallace Wong
>>> 
>>> 
>>> 
>>> tbaker73 wrote:
>>>> 
>>>> James, could you please provide an example of the connection factory
>>>> entry to add under <connection-factories> in a -ds.xml file that would
>>>> accomplish what you suggest? How would it differ from this entry?
>>>>    <tx-connection-factory>
>>>>       <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>>>       <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>
>>>> 
>>>> 
>>>> James.Strachan wrote:
>>>>> 
>>>>> 
>>>>> You'll need to setup a regular JMS connection and any destination
>>>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>>>> well work fine though - just make sure its actually normal JMS client
>>>>> objects (ConnectionFactory & destinations) - and not RA stuff.  Also
>>>>> make sure the J2EE server and your stand alone client are using the
>>>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>>>> to transmit the Java objects in JNDI
>>>>> -- 
>>>>> 
>>>>> James
>>>>> -------
>>>>> http://radio.weblogs.com/0112098/
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

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


Re: JBoss integration and lookup of connection factories.

Posted by wallace <wa...@yahoo.com>.
Thanks for response.

This works for me too. But it is a very big limitation to require the client
to hard code the physical queue name (in your example, example.MyQueue). It
defeats the purpose of jndi.  The client should only need to know the jndi
name. So no code change is necessary when the server change the physical
name.

It is now a funny situation. If I lookup from activemq jndi, I have to pass
in the physical name. I can actually lookup the topic name from jboss jndi.
But if I lookup from jboss jndi, connection factory will return null (It
looks like a bug to me as context list binding returns the correct class
name).  Neither of the jndi server gets me both things right.

Thanks for your help though.
-Wallace


rachit goel wrote:
> 
> @ WALLACE
> 
> Yes i have successfully implemented the jms thing rom core java 
> application. 
> 
> if u use 
> 
>                 Properties	Initialcontext_props = null;
> 		
> 		queueName = "example.MyQueue";
> 		
> 		Initialcontext_props = new Properties();
> 		Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> 		Initialcontext_props.put(Context.PROVIDER_URL, "tcp://app-minim:61616");
> 	
> Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
> 		Initialcontext_props.put("queue.MyQueue" , queueName);
> 
> 	       jndiContext = new InitialContext(Initialcontext_props);
> 
> 
> it will work just fine . Also make sure u have addedd the active-mq's jar
> file in ur classpath.
> 
> 
> 
> wallace wrote:
>> 
>> I can make the jndi lookup working within jboss j2ee container. But jndi
>> apparently does not work from a single standalone client, when accessing
>> jndi of jboss.
>> 
>> For example,
>>            Properties env2 = new Properties();
>>            ......
>>            env2.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.jnp.interfaces.NamingContextFactory");
>>            env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>>            InitialContext jndi2 = new InitialContext(env2);          
>>            
>>            TopicConnectionFactory connectionFactory =
>> (javax.jms.TopicConnectionFactory)
>> jndi2.lookup("java:activemq/TopicConnectionFactory");
>>            
>> The code always returns name not found exception. Has anyone ever made it
>> work in standalone client?
>> 
>> -Wallace Wong
>> 
>> 
>> 
>> tbaker73 wrote:
>>> 
>>> James, could you please provide an example of the connection factory
>>> entry to add under <connection-factories> in a -ds.xml file that would
>>> accomplish what you suggest? How would it differ from this entry?
>>>    <tx-connection-factory>
>>>       <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>>       <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>
>>> 
>>> 
>>> James.Strachan wrote:
>>>> 
>>>> 
>>>> You'll need to setup a regular JMS connection and any destination
>>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>>> well work fine though - just make sure its actually normal JMS client
>>>> objects (ConnectionFactory & destinations) - and not RA stuff.  Also
>>>> make sure the J2EE server and your stand alone client are using the
>>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>>> to transmit the Java objects in JNDI
>>>> -- 
>>>> 
>>>> James
>>>> -------
>>>> http://radio.weblogs.com/0112098/
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

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


Re: JBoss integration and lookup of connection factories.

Posted by wallace <wa...@yahoo.com>.
Thanks for response.

This works for me too. But it is a very big limitation to require the client
to hard code the physical queue name (in your example, example.MyQueue). It
defeats the purpose of jndi.  The client should only need to know the jndi
name. So no code change is necessary when the server change the physical
name.

It is now a funny situation. If I lookup from activemq jndi, I have to pass
in the physical name. I can actually lookup the topic name from jboss jndi.
But if I lookup from jboss jndi, connection factory will return null (It
looks like a bug to me as context list binding returns the correct class
name).  Neither of the jndi server gets me both things right.

Thanks for your help though.
-Wallace


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


Re: JBoss integration and lookup of connection factories.

Posted by rachit goel <pa...@yahoo.co.uk>.
@ WALLACE

Yes i have successfully implemented the jms thing rom core java 
application. 

if u use 

                Properties	Initialcontext_props = null;
		
		queueName = "example.MyQueue";
		
		Initialcontext_props = new Properties();
		Initialcontext_props.put(Context.INITIAL_CONTEXT_FACTORY ,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
		Initialcontext_props.put(Context.PROVIDER_URL, "tcp://app-minim:61616");
		Initialcontext_props.put("connectionFactoryNames","jms/QueuecConFactory");
		Initialcontext_props.put("queue.MyQueue" , queueName);

	       jndiContext = new InitialContext(Initialcontext_props);


it will work just fine . Also make sure u have addedd the active-mq's jar
file in ur classpath.



wallace wrote:
> 
> I can make the jndi lookup working within jboss j2ee container. But jndi
> apparently does not work from a single standalone client, when accessing
> jndi of jboss.
> 
> For example,
>            Properties env2 = new Properties();
>            ......
>            env2.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.jnp.interfaces.NamingContextFactory");
>            env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
>            InitialContext jndi2 = new InitialContext(env2);          
>            
>            TopicConnectionFactory connectionFactory =
> (javax.jms.TopicConnectionFactory)
> jndi2.lookup("java:activemq/TopicConnectionFactory");
>            
> The code always returns name not found exception. Has anyone ever made it
> work in standalone client?
> 
> -Wallace Wong
> 
> 
> 
> tbaker73 wrote:
>> 
>> James, could you please provide an example of the connection factory
>> entry to add under <connection-factories> in a -ds.xml file that would
>> accomplish what you suggest? How would it differ from this entry?
>>    <tx-connection-factory>
>>       <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>       <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>
>> 
>> 
>> James.Strachan wrote:
>>> 
>>> 
>>> You'll need to setup a regular JMS connection and any destination
>>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>>> well work fine though - just make sure its actually normal JMS client
>>> objects (ConnectionFactory & destinations) - and not RA stuff.  Also
>>> make sure the J2EE server and your stand alone client are using the
>>> exact same ActiveMQ jars since its gonna be using Java serialization
>>> to transmit the Java objects in JNDI
>>> -- 
>>> 
>>> James
>>> -------
>>> http://radio.weblogs.com/0112098/
>>> 
>>> 
>> 
>> 
> 
> 

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


Re: JBoss integration and lookup of connection factories.

Posted by wallace <wa...@yahoo.com>.
I can make the jndi lookup working within jboss j2ee container. But jndi
apparently does not work from a single standalone client, when accessing
jndi of jboss.

For example,
           Properties env2 = new Properties();
           ......
           env2.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
           env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
           InitialContext jndi2 = new InitialContext(env2);          
           
           TopicConnectionFactory connectionFactory =
(javax.jms.TopicConnectionFactory)
jndi2.lookup("java:activemq/TopicConnectionFactory");
           
The code always returns name not found exception. Has anyone ever made it
work in standalone client?

-Wallace Wong



tbaker73 wrote:
> 
> James, could you please provide an example of the connection factory entry
> to add under <connection-factories> in a -ds.xml file that would
> accomplish what you suggest? How would it differ from this entry?
>    <tx-connection-factory>
>       <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>       <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>
> 
> 
> James.Strachan wrote:
>> 
>> 
>> You'll need to setup a regular JMS connection and any destination
>> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
>> well work fine though - just make sure its actually normal JMS client
>> objects (ConnectionFactory & destinations) - and not RA stuff.  Also
>> make sure the J2EE server and your stand alone client are using the
>> exact same ActiveMQ jars since its gonna be using Java serialization
>> to transmit the Java objects in JNDI
>> -- 
>> 
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>> 
>> 
> 
> 

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


Re: JBoss integration and lookup of connection factories.

Posted by tbaker73 <to...@earthlink.net>.
James, could you please provide an example of the connection factory entry to
add under <connection-factories> in a -ds.xml file that would accomplish
what you suggest? How would it differ from this entry?
   <tx-connection-factory>
      <jndi-name>activemq/QueueConnectionFactory</jndi-name>
      <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>


James.Strachan wrote:
> 
> 
> You'll need to setup a regular JMS connection and any destination
> objects you want in JNDI somewhere. Using JBoss's JNDI provider could
> well work fine though - just make sure its actually normal JMS client
> objects (ConnectionFactory & destinations) - and not RA stuff.  Also
> make sure the J2EE server and your stand alone client are using the
> exact same ActiveMQ jars since its gonna be using Java serialization
> to transmit the Java objects in JNDI
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

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


Re: JBoss integration and lookup of connection factories.

Posted by James Strachan <ja...@gmail.com>.
On 1/23/07, Paul Moser <ap...@paulmoser.co.uk> wrote:
>
>
>
> James.Strachan wrote:
> >
> > On 1/23/07, Paul Moser <ap...@paulmoser.co.uk> wrote:
> >> I'm having problems looking up connection factories via JNDI, from a
> >> standalone Java client when ActiveMQ is integrated with JBoss using a
> >> RAR.
> >
> > ....
> >
> > Also the ActiveMQ Resource Adapter should not be used from a stand
> > alone client - its only to be used inside a J2EE container (or MDP
> > container like Jencks).
> >
> >
>
> Sorry, I think I may have explained what I was trying to do badly. I've used
> the ActiveMQ Resource Adapter to integrate ActiveMQ with JBoss so that my
> MDBs use queues/topics actually on the embeded ActiveMQ broker rather than
> JBossMQ/Messaging.
>
> I also need to be able to submit/receive messages from one of the
> queues/topics via a stand alone Java client, for this I've used standard
> JMS/JNDI code, it knows nothing of the ActiveMQ RAR at all. It's the JNDI
> lookup of the connection factory from this client to the J2EE server that
> produces the strange result.

Yes - and thats what I was trying to explain but badly - don't use the
J2EE servers JNDI  for a stand alone client if you can help it. JMS is
not like EJB where you access resources remotely hosted in the J2EE
server - you should try use a stand alone client JNDI provider, like
Sun's file system or ActiveMQ's JNDI provider.


> Unfortunately I don't have much control over
> the clients, they are expecting to be able to find the connections
> factories/topics/queues in the same JNDI tree as several EJB remote home
> interfaces.

Damn


> Are the connection factories/queues/topics just exposed by the RAR for use
> within the J2EE server only.

Yes - as they are not using the regular JMS client API - they are
using J2EE RA stuff

You'll need to setup a regular JMS connection and any destination
objects you want in JNDI somewhere. Using JBoss's JNDI provider could
well work fine though - just make sure its actually normal JMS client
objects (ConnectionFactory & destinations) - and not RA stuff.  Also
make sure the J2EE server and your stand alone client are using the
exact same ActiveMQ jars since its gonna be using Java serialization
to transmit the Java objects in JNDI


To be completely honest, JNDI causes way more pain than its really
worth. You could get rid of all your JNDI pain by adding *one* line of
Java code to your application code...

ConnectionFactory factory = new ActiveMQConnectionFactory();

If you find a single line of code really offensive, then using Spring
is much much easier with way less configuration/deployment issues than
JNDI. But if you really wanna go ahead and use a remote JNDI provider
to configure the connection factory it should work - just make sure
you use the JMS API and not J2EE JCA/RA stuff

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: JBoss integration and lookup of connection factories.

Posted by Paul Moser <ap...@paulmoser.co.uk>.


James.Strachan wrote:
> 
> On 1/23/07, Paul Moser <ap...@paulmoser.co.uk> wrote:
>> I'm having problems looking up connection factories via JNDI, from a
>> standalone Java client when ActiveMQ is integrated with JBoss using a
>> RAR.
> 
> ....
> 
> Also the ActiveMQ Resource Adapter should not be used from a stand
> alone client - its only to be used inside a J2EE container (or MDP
> container like Jencks).
> 
> 

Sorry, I think I may have explained what I was trying to do badly. I've used
the ActiveMQ Resource Adapter to integrate ActiveMQ with JBoss so that my
MDBs use queues/topics actually on the embeded ActiveMQ broker rather than
JBossMQ/Messaging.

I also need to be able to submit/receive messages from one of the
queues/topics via a stand alone Java client, for this I've used standard
JMS/JNDI code, it knows nothing of the ActiveMQ RAR at all. It's the JNDI
lookup of the connection factory from this client to the J2EE server that
produces the strange result. Unfortunately I don't have much control over
the clients, they are expecting to be able to find the connections
factories/topics/queues in the same JNDI tree as several EJB remote home
interfaces.

Are the connection factories/queues/topics just exposed by the RAR for use
within the J2EE server only. 

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


Re: JBoss integration and lookup of connection factories.

Posted by James Strachan <ja...@gmail.com>.
On 1/23/07, Paul Moser <ap...@paulmoser.co.uk> wrote:
> I'm having problems looking up connection factories via JNDI, from a
> standalone Java client when ActiveMQ is integrated with JBoss using a RAR.


FWIW when using JMS, JNDI is a purely client side thing; so its got
nothing to do with the RAR.  The RAR is mainly just used to allow
integration of a JMS client with an MDB/EJB server. (Am also not sure
what happens if you try using a remote JNDI server to host client side
JMS client objects)

Also the ActiveMQ Resource Adapter should not be used from a stand
alone client - its only to be used inside a J2EE container (or MDP
container like Jencks).


So I'd recommend ignoring the RAR completely on the stand alone client
and just use ActiveMQ's JNDI provider (with easy to edit properties
file)

http://incubator.apache.org/activemq/jndi-support.html


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: [Spam: 5.0] JBoss integration and lookup of connection factories.

Posted by kukusz <lu...@gmail.com>.
You want to have:

<use-java-context>false</use-java-context>

If you want to avoid using the "java:" prefix.  You can find this info 
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources here 
-- 
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463s2354.html#a9361304
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: JBoss integration and lookup of connection factories.

Posted by "Dan.Connelly" <Da...@state.vt.us>.
It is an oddity of JBoss JNDI that when you have

 <tx-connection-factory>
      <jndi-name>testing/TopicConnectionFactory</jndi-name> 
...
</tx-connection-factory>

then you have to do the JNDI lookup as follows outside of the J2EE
container:

ref = jndiContext.lookup("java:testing/TopicConnectionFactory"); 

The Topic resource, on the other hand, is looked up exactly as named in the
XML.

At least, that is what I do, and it works.    Its a JBoss convention, I
believe, that "datasource" JNDI names have a "java:" prefix. 

I do not have an explanation for this.    least, that has been my
experience.
-- 
View this message in context: http://www.nabble.com/JBoss-integration-and-lookup-of-connection-factories.-tf3061463.html#a8524030
Sent from the ActiveMQ - User mailing list archive at Nabble.com.