On 4/25/07, tonyc <[EMAIL PROTECTED]> wrote:
Hi, I just downloaded activeMQ 4.1.1 to learn something about message queues. I started the message broker and used example code to run a JMS client. I tried to follow the instructions in JNDI support to use JNDI names but had no luck, I keep getting a javax.naming.NameNotFoundException error. have included the error message below. I created a jndi.properties file based on the example shown. have also included the contents below. I tried placing the jndi.properties file in my own jar file "jndi.jar" which i refer to in the classpath. I also placed the jndi.properties in the apache-activemq-4.1.1.jar . I am not sure whether the jndi.properties file has to be placed in a particular location in the jar. Tried a few things but still I keep getting the error message.
Its usually easiest to put the jndi.properties file in a directory which is on the classpath; but it should be found if its in the root directory of a jar
i have also included a java code snippet. would appreciate any help. thanks tony JMS CLIENT CODE SNIPPET: ================= ConnectionFactory connectionFactory = null; Destination dest = null; try { connectionFactory = (ConnectionFactory) jndiContext.lookup("ConnectionFactory");
Note that this string "ConnectionFactory" is the JNDI name to use - which you changed to "connectionFactory" in your editted jndi.properties....
} catch (Exception e) { System.out.println("JNDI API lookup for connection failed: " + e.toString()); e.printStackTrace(); System.exit(1); } try{ dest = (Destination) jndiContext.lookup(destName); } catch (Exception e) { System.out.println("JNDI API for dest lookup failed: " + e.toString()); e.printStackTrace(); System.exit(1); } JNDI PROPERTIES: =========== java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory # use the following property to configure the default connector java.naming.provider.url = tcp://localhost:61616 # use the following property to specify the JNDI name the connection factory # should appear as. #jms.ConnectionFactory = ConnectionFactory connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
So it looks like you've overloaded what names you want the connection factory to appear as. If you comment out this line (ie. use the example jndi.properties file without changing it) your code would work -- James ------- http://radio.weblogs.com/0112098/