Reputation: 892
i tried to publish message to activemq.but i am getting one naming exception in my java application. here is the code follows
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL,"tcp://localhost:61616");
InitialContext ctx = new InitialContext(props);
// get the initial context
// InitialContext ctx = new InitialContext();
QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
// create a queue connection
QueueConnection queueConn = connFactory.createQueueConnection();
// lookup the queue object
Queue queue = (Queue) ctx.lookup("nixon");
i am getting three warning plus below one error like this
Exception in thread "main" javax.naming.NameNotFoundException: nixon
at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.youtube.rest2.status.ProducerNewClient.main(ProducerNewClient.java:38)
can anyone tell why i am getting this error..?
Upvotes: 0
Views: 2139
Reputation: 18356
You are most likely getting this error because you haven't configured the destinations in you JNDI configuration file. You can either add these definitions to your file or use the dynamic destination features of ActiveMQ.
For the easiest possible configuration with JNDI based programs, there are 2 dynamic contexts as follows
dynamicQueues
dynamicTopics
which allows you to lookup queues and topics using JNDI without any configuration.
e.g. if you use the following name to lookup into JNDI dynamicQueues/FOO.BAR
you will get back an ActiveMQQueue of the name "FOO.BAR".
Read the JNDI Documentation at the ActiveMQ site for more.
Upvotes: 4