You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by tonyc <an...@dpworld.com> on 2007/04/25 08:30:04 UTC

javax.naming.NameNotFoundException - JNDI

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.


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");
              } 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 


# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.jms.Queue = PhysicalQueue


# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
jms.Topic = PhysicalTopic




ERROR MESSAGE:
==========

JNDI API lookup for connection failed: javax.naming.NameNotFoundException:
Conn
ctionFactory
javax.naming.NameNotFoundException: ConnectionFactory
        at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java
215)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at
SimpleProducer.main(SimpleProducer.java:94)javax.naming.NameNotFoundException 
 

 
-- 
View this message in context: http://www.nabble.com/javax.naming.NameNotFoundException---JNDI-tf3643462s2354.html#a10175148
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: javax.naming.NameNotFoundException - JNDI

Posted by tonyc <an...@dpworld.com>.
Yes, the suggestion about the case sensititvity of the factory name was
correct.

thanks tony


tonyc 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.
> 
> 
> 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");
>               } 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 
> 
> 
> # register some queues in JNDI using the form
> # queue.[jndiName] = [physicalName]
> queue.jms.Queue = PhysicalQueue
> 
> 
> # register some topics in JNDI using the form
> # topic.[jndiName] = [physicalName]
> jms.Topic = PhysicalTopic
> 
> 
> 
> 
> ERROR MESSAGE:
> ==========
> 
> JNDI API lookup for connection failed: javax.naming.NameNotFoundException:
> Conn
> ctionFactory
> javax.naming.NameNotFoundException: ConnectionFactory
>         at
> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java
> 215)
>         at javax.naming.InitialContext.lookup(Unknown Source)
>         at
> SimpleProducer.main(SimpleProducer.java:94)javax.naming.NameNotFoundException 
>  
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/javax.naming.NameNotFoundException---JNDI-tf3643462s2354.html#a10197412
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: javax.naming.NameNotFoundException - JNDI

Posted by Anthrope <pn...@anthrope.com>.
Could it also be because you're trying to look up ConnectionFactory, whereas
you've defined an entry in your jndi.properties called connectionFactory? I
do believe the names are case-sensitive.

Prashanth


James.Strachan wrote:
> 
> On 4/25/07, tonyc <an...@dpworld.com> 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/
> 
> 

-- 
View this message in context: http://www.nabble.com/javax.naming.NameNotFoundException---JNDI-tf3643462s2354.html#a10191527
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: javax.naming.NameNotFoundException - JNDI

Posted by James Strachan <ja...@gmail.com>.
On 4/25/07, tonyc <an...@dpworld.com> 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/