Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI in JBOSS

 
Walker Rustin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gone through the material at JBoss and still not sure how JNDI works in JBOSS. Here is an example of jboss.xml. The code works but I am not sure where I am mapping java:comp/env/ejb/user to the user ejb.
<?xml version='1.0' encoding='UTF-8' ?>
<jboss>
<enterprise-beans>
<entity>
<ejb-name>UserEJB</ejb-name>
<local-jndi-name>MyUser</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/BankDB</res-ref-name>
<jndi-name>java:/DefaultDS</jndi-name>
</resource-ref>
</entity>
<session>
<ejb-name>UserControllerEJB</ejb-name>
<local-jndi-name>MyUserController</local-jndi-name>
<ejb-local-ref>
<ejb-ref-name>ejb/user</ejb-ref-name>
<local-jndi-name>MyUser</local-jndi-name>
</ejb-local-ref>
</session>
</enterprise-beans>
</jboss>
thanks.
- walk rustin
 
Asad Zaman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rustin,
You can easily find out the mapping if you look at the ejb-jar.xml.
As you've declared <ejb-local-ref> as follows:
<ejb-local-ref>
<ejb-ref-name>ejb/user</ejb-ref-name>
<local-jndi-name>MyUser</local-jndi-name>
</ejb-local-ref>
This means that you are declaring a name "user" in the JNDI ENC
tree java:comp
+- env
| +- jdbc
| | +- BankDB [link -> java:/DefaultDS]
| +- ejb
| | +- user
The BankDB name under jdbc is the JDBC name you have declated
in your ejb-jar.xml
You can look out the JNDI ENC tree of all names your JBossAS
has prepared for you.
1. Run your JBossAS
2. Open your browser and type http://localhost:8080/jmx-console
in the address bar and press enter. you should see JMX Agent View
of JBossAS. This is the MBean page of JBoss.
3. In the jboss section you should see a link service=JNDIView.
Click this link. You should now see JNDIView Service MBean view.
Scroll down the page until you can see a operation name named "list".
Press the invoke button of list operation.
You should be navagated to the result page of the list operation.
4. Find out a section named Ejb Module: xxx.jar section.
(here xxx.jar is the name of file name of your EJB).
And see what JNDI tree is constructed from your EJB by JBossAS.
Play with the jmx-console for sometime. I am sure you will
be cleared all of your Questions.
----
Asad Zaman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic