- EJB - Packaging Applications
- EJB - Web Services
- EJB - Exception Handling
- EJB - Query Language
- EJB - Access Database
- EJB - Entity Relationships
- EJB - JNDI Bindings
- EJB - Security
- EJB - Transactions
- EJB - Blobs/Clobs
- EJB - Embeddable Objects
- EJB - Interceptors
- EJB - Dependency Injection
- EJB - Timer Service
- EJB - Callbacks
- EJB - Annotations
- EJB - Message Driven Beans
- EJB - Persistence
- EJB - Stateful Bean
- EJB - Stateless Bean
- EJB - Create Application
- EJB - Environment Setup
- EJB - Overview
- EJB - Home
EJB Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
EJB - JNDI Bindings
JNDI stands for Java Naming and Directory Interface. It is a set of API and service interfaces. Java based apppcations use JNDI for naming and directory services. In context of EJB, there are two terms.
Binding − This refers to assigning a name to an EJB object, which can be used later.
Lookup − This refers to looking up and getting an object of EJB.
In Jboss, session beans are bound in JNDI in the following format by default.
local − EJB-name/local
remote − EJB-name/remote
In case, EJB are bundled with <apppcation-name>.ear file, then default format is as following −
local − apppcation-name/ejb-name/local
remote − apppcation-name/ejb-name/remote
Example of Default Binding
Refer to EJB - Create Apppcation chapter s JBoss console output.
JBoss Apppcation Server Log Output
... 16:30:02,723 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=EjbComponent.jar,name=LibrarySessionBean,service=EJB3 16:30:02,723 INFO [EJBContainer] STARTED EJB: com.tutorialspoint.stateless.LibrarySessionBean ejbName: LibrarySessionBean 16:30:02,731 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI: LibrarySessionBean/remote - EJB3.x Default Remote Business Interface LibrarySessionBean/remote-com.tutorialspoint.stateless.LibrarySessionBeanRemote - EJB3.x Remote Business Interface ...
Customized Binding
Following annotations can be used to customize the default JNDI bindings −
local − org.jboss.ejb3.LocalBinding
remote − org.jboss.ejb3.RemoteBindings
Update LibrarySessionBean.java. Refer to EJB - Create Apppcation chapter.
LibrarySessionBean
package com.tutorialspoint.stateless; import java.util.ArrayList; import java.util.List; import javax.ejb.Stateless; @Stateless @LocalBinding(jndiBinding="tutorialsPoint/pbrarySession") pubpc class LibrarySessionBean implements LibrarySessionBeanLocal { List<String> bookShelf; pubpc LibrarySessionBean() { bookShelf = new ArrayList<String>(); } pubpc void addBook(String bookName) { bookShelf.add(bookName); } pubpc List<String> getBooks() { return bookShelf; } }
LibrarySessionBeanLocal
package com.tutorialspoint.stateless; import java.util.List; import javax.ejb.Local; @Local pubpc interface LibrarySessionBeanLocal { void addBook(String bookName); List getBooks(); }
Build the project, deploy the apppcation on Jboss, and verify the following output in Jboss console −
... 16:30:02,723 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=EjbComponent.jar,name=LibrarySessionBean,service=EJB3 16:30:02,723 INFO [EJBContainer] STARTED EJB: com.tutorialspoint.stateless.LibrarySessionBean ejbName: LibrarySessionBean 16:30:02,731 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI: tutorialsPoint/pbrarySession - EJB3.x Default Local Business Interface tutorialsPoint/pbrarySession-com.tutorialspoint.stateless.LibrarySessionBeanLocal - EJB3.x Local Business Interface ...Advertisements