问题
We migrated from Jboss EAP 5
to EAP 6 in our development environment.
I now see the following in my JBOSS
logs. I am trying to understand how this binding happens. I have read JBOSS docs
on JNDI namespace binding. Still I am not totally clear how it works. Here is my log.
java:global/customerCare/services/UserDaoImpl!com.example.services.UserDao
java:app/services/UserDaoImpl!com.example.services.UserDao
java:module/UserDaoImpl!com.services.UserDao
java:global/customerCare/services/UserDaoImpl
java:app/services/UserDaoImpl
java:module/UserDaoImpl
Here are my EJBs
@Local
public interface UserDao {
public static final String JNDI_NAME = "java:global/customCare/services/UserDaoImpl";
//interface methods here
}
@Stateless
public class UserDaoImpl implements UserDao {
// implement methods
}
My doubts are:
I explicitly had
JNDI binding
to bejava:global/customCare/services/UserDaoImpl
in myUserDao
interface. Then why do I see I binding for others such asapp
andmodule
.what is the difference between
app
andmodule
? when would binding to these components be needed? some example here to illustrate will be very helpfulThe last three lines of log show binding to
UserDaoImpl
. Is it something that JBoss does without I ask it to bind? ( I set onlyUserDao
but notUserDaoImpl
for JNDI binding).
I am a bit illiterate on JNDI Namespace
binding. Reading docs helped me but not to great extent.
Thanks
回答1:
I can answer doubt 2: All the names are the same thing but with different contexts.
The global name is a full JNDI context that is used to bind globally, ie. from a client or from another EAR file
The module name can be used to bind within the same application, ie different EJBs within the same EAR
The local name is used to bind locally, ie within an jar or war.
It is slightly more efficient to use the shorter names to bind locally than specifying a full global name each time.
From what I have seen JBoss EAP 6 will always list the three / six names for every enterprise bean during deployment. It is intended to help you as a developer identify the JNDI name(s) for the bean.
来源:https://stackoverflow.com/questions/29039353/what-is-the-difference-between-jndi-binding-of-module-and-app-in-java-ee-6-7