I am new to ActiveMQ and have only been programming in Java for a couple
of years so JNDI is a new concept for me as well. I walked through some
JMS tutorials using ActiveMQ and even modified and built new java apps
that used JMS. Having done that, I created a class which handles all my
JMS methods and used that within a Tomcat servlet. That is where my
problems started. It took me a while, but I finally figued out where to
place the jndi.properties file and when I use jndiContext = new
InitialContext(); and view the context information I see all my queue
entries. So far, so good, however when I use the following:
queueConnectionFactory = (QueueConnectionFactory)
jndiContext.lookup("ConnectionFactory");
I get a: javax.naming.NameNotFoundException: Name ConnectionFactory is
not bound in this Context.
I am stumped! I can see that the jndi properties file is loaded because
I can view the context in my code. If I change the file entries, I see
those changes in the context so I know that it is reading the correct
jndi.properties file. Here is the jndi.properties content:
java.naming.factory.initial=org.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://localhost:61616
queue.ApplicantQueue = ApplicantQueue
queue.EmployeeQueue = EmployeeQueue
queue.BenefitQueue = BenefitQueue
queue.StatusQueue = StatusQueue
This exact same jndi.properties file is used in the project that I used
to create the java applications in. The only difference here is that
this is a different Eclipse project and it is a servlet running in
Tomcat, rather than a java application.
Environment is:
jdk 1.4.2_06
tomcat 5.0.28
ActiveMQ 3.2.2
Any pointers on how I can solve this?