views:

1165

answers:

4

I am trying to look up a QueueConnectionFactory and Queue via Geronimo's JNDI. The Queue gets returned fine, but the QueueConnectionFactory lookup always returns null. It doesn't throw a NamingException, which is what I'd expect if the JNDI name was incorrect.

Can anyone see what I'm doing wrong? The test code below outputs:

true
false

import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class JndiTest
{
    private final static String QUEUE_NAME = "jca:/org.apache.geronimo.configs/activemq-ra/JCAAdminObject/SendReceiveQueue";
    private final static String FACTORY_NAME = "jca:/org.apache.geronimo.configs/activemq-ra/JCAManagedConnectionFactory/DefaultActiveMQConnectionFactory";

    public static void main(String[] args) throws NamingException
    {
     InitialContext ctx = new InitialContext();
     QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup(FACTORY_NAME);
     Queue queue = (Queue)ctx.lookup(QUEUE_NAME);
     System.out.println(factory == null);
     System.out.println(queue == null);  
    }

}
In case it makes a difference: I've added openejb-client-3.0.1.jar, geronimo-ejb_3.0_spec-1.0.1.jar and activemq-core-4.1.2-G20090207.jar to my class path, and my jndi.properties file has the properties:
java.naming.factory.initial = org.apache.openejb.client.RemoteInitialContextFactory
java.naming.provider.url = ejbd://127.0.0.1:4201
A: 

There's two participants here, you're looking in JNDI for something. Somebody else had to put it there. I don't know the specifics of your environment but my approach to such problems is

  • explore the namespace - what's there? Do you have any JNDI browing tools?
  • look carfeully in the logs for the service that is supposed to be registering with JNDI, does it report any errors?
djna
Geronimo provides a JNDI browsing tool, and both JNDI names appear to be there. Changing the names in my test tool produce a NamingException, so it must be finding *something*.
Simon Nickerson
Right, but what is it finding and who put it there? To me all of this points to the problem being in the JMS provider rather than your code.
djna
A: 

perhaps this liks might give you a direction to solve your problem: http://fixunix.com/websphere/357758-jndi-lookup-webservice-returning-null.html

+7  A: 
techzen
Wow. Thanks for the thoughtful, thorough answer.
Stephen Harmon
+1  A: 
Antoine Claval