activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xy_wen <wxy2...@hotmail.com>
Subject Re: Exception occur when JNDI lookup
Date Fri, 07 Dec 2007 02:53:46 GMT

Thanks for your help.I try as your suggestion,there is another exception like
this:
Exception in thread "main" javax.naming.NameNotFoundException: jmsreMsgTopic
	at
org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:215)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at SentRequestMessage.run(SentRequestMessage.java:55)
	at SentRequestMessage.main(SentRequestMessage.java:43)
I created a jndi.propertise file under the classpath.The content of the
jndi.propertise is:
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. 
connectionFactoryNames = jmsConnectionFactory

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
# queue.MyQueue = example.MyQueue


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

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

And motify the test client like this:
	Context contxt = new InitialContext();
		
		ActiveMQConnectionFactory factory =
(ActiveMQConnectionFactory)contxt.lookup("ConnectionFactory");
		connection = factory.createConnection();
		session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
		
		sender = session.createProducer((Topic)contxt.lookup("jmsreMsgTopic"));
		sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
		
	
session.createConsumer((Topic)contxt.lookup("jmsreMsgControl")).setMessageListener(this);
		connection.start();

James.Strachan wrote:
> 
> On 06/12/2007, xy_wen <wxy2001@hotmail.com> wrote:
>>
>> I am using tomcat 5.5 with Activemq 4.1.1.I have written a simple test
>> example to get the connectfatory and topic information using JNDI.
>> this is my test client:
>>          InitialContext iniContxt = new InitialContext();
>>          Context contxt = (Context)
>> iniContxt.lookup("java:comp/env/jmsConnectionFactory");
>>          ActiveMQConnectionFactory factory =
>> (ActiveMQConnectionFactory)iniContxt.lookup("jmsConnectionFactory");
>>          connection = factory.createConnection();
>>         session =
>> connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
>>         sender =
>> session.createProducer((Topic)iniContxt.lookup("jmsreMsgTopic"));
>>         sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>> But there is a exception when excute "Context contxt = (Context)
>> iniContxt.lookup("java:comp/env/jmsConnectionFactory");"
>> The exception is :
>> Exception in thread "main" javax.naming.NamingException: scheme java not
>> recognized
>>         at
>> org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:199)
> 
> You're using ActiveMQ's JNDI provider which is configured in the
> jndi.properties rather than the web.xml (and doesn't use the java:env
> stuff).
> 
> Either use the names from ActiveMQ's JNDI provider...
> http://activemq.apache.org/jndi-support.html
> 
> Or switch to using your servlet containers JNDI provider
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-occur-when-JNDI-lookup-tf4954290s2354.html#a14205908
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message