• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.naming .NameNotFoundException:

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have integrated ActiveMQ. ActiveMq connectionfactory has been bound to the JNDI name 'java:activemq/QueueConnectionFactory'.

11:21:03,670 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding
,name=activemq/QueueConnectionFactory' to JNDI name 'java:activemq/QueueConnectionFactory'


In the client I am trying to do the JNDI lookup of the connection factory.

ic = new InitialContext();
cf = (ConnectionFactory)ic.lookup("activemq/QueueConnectionFactory");

I am getting


I am going
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question: When you say 'client' is it a standalone client? If yes then the java namespace of the server wont be visible to this client.

The other part, instead of the code below:

ic = new InitialContext();
cf = (ConnectionFactory)ic.lookup("activemq/QueueConnectionFactory");

Try this out:
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My client is running outside of JBoss. I tried as.It did not work.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternately, you can try the following:

- Go to http://localhost:8080/jmx-console
- You will find service=JNDIView
- Click on it
- On the page that comes up, click on the Invoke button next to the 'list' method
- The next page that comes up will display the jndi names and the corresponding objects bound to the JNDI
- In this list of jndi names check where your object is bound
- If you are not able to decipher the contents of the JNDI tree, post the output here.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My client is running outside of JBoss.


That explains it. The java:/ namespace will NOT be visible to a standalone client.

How have you configured the ActiveMQ ConnectionFactory? Can you post the configuration file
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am seeing it under java: Namespace

+- activemq (class: org.jnp.interfaces.NamingContext)
| +- QueueConnectionFactory (class: org.apache.activemq.ra.ActiveMQConnectionFactory)
| +- TopicConnectionFactory (class: org.apache.activemq.ra.ActiveMQConnectionFactory)

Should it be under global JNDI Namespace?
[ August 30, 2006: Message edited by: Pradip Bhat ]
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
panacya-jms-ds.xml
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should it be under global JNDI Namespace?


Yes, to make it visible to the standalone client(which is outside the server JVM) you will have to configure the jndi name in the global namespace. While configuring the ConnectionFactory, you can do it in the xml file.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jaikiran pai:


Yes, to make it visible to the standalone client(which is outside the server JVM) you will have to configure the jndi name in the global namespace. While configuring the ConnectionFactory, you can do it in the xml file.


How I do that in the above xml file.Thanks for your help so far.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradip Bhat:


Try this one:



I guess, you wont get the NameNotFoundException after this change, but you might observe that the object that is returned is null(not sure though).
Let us know about the outcome.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works but I am getting null object.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works but I am getting null object.


These links might help:

JBoss JCA Forum

Getting null when doing a lookup on ConnectionFactory?

These links mention the reason why the Connection factory is not available outside the app server
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Now I have moved the client code inside of JBoss.
 
Tom Baker
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an option to run this from a standalone application however? What if the client code cannot run in the same JBoss container where active-mq is deployed?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic