I am trying to write a simple JMS client (external) which will lookup the
ConnectionFactory and destination using JNDI and send a message to the
destination without using any 3rd party or ActiveMq API's. 
For this I customized loanbroker example by removing all the classes except
for JMSClient and 
LoanBroker. 

This is the snippet of my JMSClient 

 Properties props = new Properties(); 
            props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory" ); 
            props.put(Context.PROVIDER_URL, "tcp://localhost:61616/"); 
            jndiContext = new InitialContext(props);   
         connectionFactory = (ConnectionFactory)
jndiContext.lookup("ConnectionFactory"); 
             dest = (Destination) jndiContext.lookup("jndiEx.source"); 
            connection = connectionFactory.createConnection(); 
           Session session = connection.createSession(false, 
           Session.CLIENT_ACKNOWLEDGE); 
           MessageProducer producer = session.createProducer(dest); 
           producer.send(session.createTextMessage("<message>Hello,
world!</message>")); 

I have configured the same destination name in servicemix.xml file. I
successfully built and deployed this SA into Servicemix. When I run, the
follow exception is thrown 

JNDI API lookup failed: javax.naming.NameNotFoundException: jndiEx.source 
javax.naming.NameNotFoundException: jndiEx.source 
    at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215) 

1. Please help me out to resolve this issue? 
2. Is it possible to use SpringInitialContextFactory and implement the same? 
3. If I have to use jndi.properties to configure ConnectionFactory and
destination name as per http://activemq.apache.org/jndi-support.html, then
where do I need to keep this property file so that it is used only for this
example. 

Thanks in advance
-- 
View this message in context: 
http://www.nabble.com/Help---JNDI-lookup-failing-tf4801867s12049.html#a13739048
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to