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

Reply via email to