You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Javier Leyba <xl...@gmail.com> on 2006/07/06 11:23:29 UTC

Problem binding activemqfactory

Hi

I´m working with ActiveMQ and JBoss.

I want to create an ActiveMQConnectionFactory and store it in JBoss
JNDI to allow my publishers to get connectionFactory from JNDI
context.

To try how to do it I did a simple program:

------------
public class Test {

		public static void main(String[] args) {
			try {
				try {
					Hashtable p = new Hashtable();
					p.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
					p.put("java.naming.provider.url", "jnp://172.31.112.9:2199");
					p.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");

					
					Context c = new InitialContext(p);															
					System.out.println("trying to bind");
					c.bind("cf", "sdvsdv");
					System.out.println("bind done");
					
					ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("failover://(tcp://172.31.112.9:62002,tcp://172.31.112.9:62011)?randomize=false&connectionTimeout=20000&soTimeout=10000&wireFormat.maxInactivityDuration=20000");
					
					if (connectionFactory != null) {	
						System.out.println("cf is: " + connectionFactory.getBrokerURL());
					} else {
						System.out.println("Was null");
					}
					
					c.bind("cf1", connectionFactory);
										
				} catch (Exception e) {
					e.printStackTrace();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
}

------------

But when I run this, I receive the exception:

---------

trying to bind
bind done
cf es: failover://(tcp://172.31.112.9:62002,tcp://172.31.112.9:62011)?randomize=false&connectionTimeout=20000&soTimeout=10000&wireFormat.maxInactivityDuration=20000
-
java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:393)
	at java.util.Properties.setProperty(Properties.java:102)
	at org.apache.activemq.ActiveMQConnectionFactory.populateProperties(ActiveMQConnectionFactory.java:414)
	at org.apache.activemq.jndi.JNDIBaseStorable.getProperties(JNDIBaseStorable.java:67)
	at org.apache.activemq.jndi.JNDIReferenceFactory.createReference(JNDIReferenceFactory.java:98)
	at org.apache.activemq.jndi.JNDIBaseStorable.getReference(JNDIBaseStorable.java:79)
	at org.jnp.interfaces.NamingContext.bind(NamingContext.java:537)
	at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
	at javax.naming.InitialContext.bind(InitialContext.java:355)
	at Test.main(Test.java:33)
javax.naming.NamingException
	at org.apache.activemq.jndi.JNDIReferenceFactory.createReference(JNDIReferenceFactory.java:108)
	at org.apache.activemq.jndi.JNDIBaseStorable.getReference(JNDIBaseStorable.java:79)
	at org.jnp.interfaces.NamingContext.bind(NamingContext.java:537)
	at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
	at javax.naming.InitialContext.bind(InitialContext.java:355)
	at Test.main(Test.java:33)

------------------

I really have no idea about the origin of the problem, but evidently
is not JNDI because I can  make this bind c.bind("cf", "sdvsdv");
without problems.

How could I store a connectionfactory in JNDI ?

Could somebody give me a clue ?


Thanks in advance


-- 
Javier Leyba
Barcelona - Spain

Re: Problem binding activemqfactory

Posted by Adrian Co <ac...@exist.com>.
Hi,

This is a recent fix, I'm not sure if it made it to the 4.0.1 release. 
You could try the nightly build for 4.1 if you want:
http://people.apache.org/maven-snapshot-repository/incubator-activemq/incubator-activemq/4.1-SNAPSHOT/incubator-activemq-4.1-20060607.074435-1.zip

or you could set the clientID, username, and password to an empty string 
before binding (I think this should work as a simple workaround). :)

Regards,
Adrian Co

James Strachan wrote:
> I wonder if you could upgrade to a recent release of ActiveMQ such as
> 4.0.1? The stack trace doesn't seem to map to the current code for
> ActiveMQConnectionFactory and from reading the code there are null
> checks for all the values being put into the Properties object so I
> don't see how that exception could be thrown with the latest code.
>
>
> On 7/6/06, Javier Leyba <xl...@gmail.com> wrote:
>> Hi
>>
>> I´m working with ActiveMQ and JBoss.
>>
>> I want to create an ActiveMQConnectionFactory and store it in JBoss
>> JNDI to allow my publishers to get connectionFactory from JNDI
>> context.
>>
>> To try how to do it I did a simple program:
>>
>> ------------
>> public class Test {
>>
>>                 public static void main(String[] args) {
>>                         try {
>>                                 try {
>>                                         Hashtable p = new Hashtable();
>>                                         
>> p.put("java.naming.factory.url.pkgs",
>> "org.jboss.naming:org.jnp.interfaces");
>>                                         
>> p.put("java.naming.provider.url", "jnp://172.31.112.9:2199");
>>                                         
>> p.put("java.naming.factory.initial",
>> "org.jnp.interfaces.NamingContextFactory");
>>
>>
>>                                         Context c = new 
>> InitialContext(p);
>>                                         System.out.println("trying to 
>> bind");
>>                                         c.bind("cf", "sdvsdv");
>>                                         System.out.println("bind done");
>>
>>                                         ActiveMQConnectionFactory 
>> connectionFactory = new
>> ActiveMQConnectionFactory("failover://(tcp://172.31.112.9:62002,tcp://172.31.112.9:62011)?randomize=false&connectionTimeout=20000&soTimeout=10000&wireFormat.maxInactivityDuration=20000"); 
>>
>>
>>                                         if (connectionFactory != null) {
>>                                                 
>> System.out.println("cf is: " + connectionFactory.getBrokerURL());
>>                                         } else {
>>                                                 
>> System.out.println("Was null");
>>                                         }
>>
>>                                         c.bind("cf1", 
>> connectionFactory);
>>
>>                                 } catch (Exception e) {
>>                                         e.printStackTrace();
>>                                 }
>>                         } catch (Exception e) {
>>                                 e.printStackTrace();
>>                         }
>>
>>                 }
>> }
>>
>> ------------
>>
>> But when I run this, I receive the exception:
>>
>> ---------
>>
>> trying to bind
>> bind done
>> cf es: 
>> failover://(tcp://172.31.112.9:62002,tcp://172.31.112.9:62011)?randomize=false&connectionTimeout=20000&soTimeout=10000&wireFormat.maxInactivityDuration=20000 
>>
>> -
>> java.lang.NullPointerException
>>         at java.util.Hashtable.put(Hashtable.java:393)
>>         at java.util.Properties.setProperty(Properties.java:102)
>>         at 
>> org.apache.activemq.ActiveMQConnectionFactory.populateProperties(ActiveMQConnectionFactory.java:414) 
>>
>>         at 
>> org.apache.activemq.jndi.JNDIBaseStorable.getProperties(JNDIBaseStorable.java:67) 
>>
>>         at 
>> org.apache.activemq.jndi.JNDIReferenceFactory.createReference(JNDIReferenceFactory.java:98) 
>>
>>         at 
>> org.apache.activemq.jndi.JNDIBaseStorable.getReference(JNDIBaseStorable.java:79) 
>>
>>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:537)
>>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
>>         at javax.naming.InitialContext.bind(InitialContext.java:355)
>>         at Test.main(Test.java:33)
>> javax.naming.NamingException
>>         at 
>> org.apache.activemq.jndi.JNDIReferenceFactory.createReference(JNDIReferenceFactory.java:108) 
>>
>>         at 
>> org.apache.activemq.jndi.JNDIBaseStorable.getReference(JNDIBaseStorable.java:79) 
>>
>>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:537)
>>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
>>         at javax.naming.InitialContext.bind(InitialContext.java:355)
>>         at Test.main(Test.java:33)
>>
>> ------------------
>>
>> I really have no idea about the origin of the problem, but evidently
>> is not JNDI because I can  make this bind c.bind("cf", "sdvsdv");
>> without problems.
>>
>> How could I store a connectionfactory in JNDI ?
>>
>> Could somebody give me a clue ?
>>
>>
>> Thanks in advance
>>
>>
>> -- 
>> Javier Leyba
>> Barcelona - Spain
>>
>
>


Re: Problem binding activemqfactory

Posted by James Strachan <ja...@gmail.com>.
I wonder if you could upgrade to a recent release of ActiveMQ such as
4.0.1? The stack trace doesn't seem to map to the current code for
ActiveMQConnectionFactory and from reading the code there are null
checks for all the values being put into the Properties object so I
don't see how that exception could be thrown with the latest code.


On 7/6/06, Javier Leyba <xl...@gmail.com> wrote:
> Hi
>
> I´m working with ActiveMQ and JBoss.
>
> I want to create an ActiveMQConnectionFactory and store it in JBoss
> JNDI to allow my publishers to get connectionFactory from JNDI
> context.
>
> To try how to do it I did a simple program:
>
> ------------
> public class Test {
>
>                 public static void main(String[] args) {
>                         try {
>                                 try {
>                                         Hashtable p = new Hashtable();
>                                         p.put("java.naming.factory.url.pkgs",
> "org.jboss.naming:org.jnp.interfaces");
>                                         p.put("java.naming.provider.url", "jnp://172.31.112.9:2199");
>                                         p.put("java.naming.factory.initial",
> "org.jnp.interfaces.NamingContextFactory");
>
>
>                                         Context c = new InitialContext(p);
>                                         System.out.println("trying to bind");
>                                         c.bind("cf", "sdvsdv");
>                                         System.out.println("bind done");
>
>                                         ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("failover://(tcp://172.31.112.9:62002,tcp://172.31.112.9:62011)?randomize=false&connectionTimeout=20000&soTimeout=10000&wireFormat.maxInactivityDuration=20000");
>
>                                         if (connectionFactory != null) {
>                                                 System.out.println("cf is: " + connectionFactory.getBrokerURL());
>                                         } else {
>                                                 System.out.println("Was null");
>                                         }
>
>                                         c.bind("cf1", connectionFactory);
>
>                                 } catch (Exception e) {
>                                         e.printStackTrace();
>                                 }
>                         } catch (Exception e) {
>                                 e.printStackTrace();
>                         }
>
>                 }
> }
>
> ------------
>
> But when I run this, I receive the exception:
>
> ---------
>
> trying to bind
> bind done
> cf es: failover://(tcp://172.31.112.9:62002,tcp://172.31.112.9:62011)?randomize=false&connectionTimeout=20000&soTimeout=10000&wireFormat.maxInactivityDuration=20000
> -
> java.lang.NullPointerException
>         at java.util.Hashtable.put(Hashtable.java:393)
>         at java.util.Properties.setProperty(Properties.java:102)
>         at org.apache.activemq.ActiveMQConnectionFactory.populateProperties(ActiveMQConnectionFactory.java:414)
>         at org.apache.activemq.jndi.JNDIBaseStorable.getProperties(JNDIBaseStorable.java:67)
>         at org.apache.activemq.jndi.JNDIReferenceFactory.createReference(JNDIReferenceFactory.java:98)
>         at org.apache.activemq.jndi.JNDIBaseStorable.getReference(JNDIBaseStorable.java:79)
>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:537)
>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
>         at javax.naming.InitialContext.bind(InitialContext.java:355)
>         at Test.main(Test.java:33)
> javax.naming.NamingException
>         at org.apache.activemq.jndi.JNDIReferenceFactory.createReference(JNDIReferenceFactory.java:108)
>         at org.apache.activemq.jndi.JNDIBaseStorable.getReference(JNDIBaseStorable.java:79)
>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:537)
>         at org.jnp.interfaces.NamingContext.bind(NamingContext.java:516)
>         at javax.naming.InitialContext.bind(InitialContext.java:355)
>         at Test.main(Test.java:33)
>
> ------------------
>
> I really have no idea about the origin of the problem, but evidently
> is not JNDI because I can  make this bind c.bind("cf", "sdvsdv");
> without problems.
>
> How could I store a connectionfactory in JNDI ?
>
> Could somebody give me a clue ?
>
>
> Thanks in advance
>
>
> --
> Javier Leyba
> Barcelona - Spain
>


-- 

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