You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Vinram <vi...@yahoo.com> on 2007/11/14 04:00:31 UTC
Help - JNDI lookup failing
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.
Re: Help - JNDI lookup failing
Posted by Jeff Yu <je...@gmail.com>.
Hi,
first, you didn't set jndiEx.source in the JNDI properties...you've only set
the provider_URL & context_factory as I can see from your code.
second. for your case, you might need to set
props.setProperties("queue.jndiEx.source", "your physical place here");
Hope This Helps
Jeff
On Nov 14, 2007 11:00 AM, Vinram <vi...@yahoo.com> wrote:
>
> 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.
>
>
--
Best Regards
Jeff