Can somebody verify my understanding.
What is the use of ejb-ref?
ejb-ref is used to tell the deployer that this bean will be referring to other bean with this name.
Is there any other use.
-
ejb-ref tag (5 messages)
- Posted by: vishal khatter
- Posted on: December 17 2003 07:16 EST
Threaded Messages (5)
- ejb-ref tag by Paul Strack on December 17 2003 09:31 EST
- ejb-ref tag by vishal khatter on December 17 2003 09:51 EST
- ejb-ref tag by Paul Strack on December 17 2003 11:40 EST
- ejb-ref tag by vishal khatter on December 17 2003 09:51 EST
- why to use java:comp/env/ejb/jndiname by vishal khatter on January 23 2004 00:15 EST
- why to use java:comp/env/ejb/jndiname by Andre Fernandes on January 23 2004 14:24 EST
-
ejb-ref tag[ Go to top ]
- Posted by: Paul Strack
- Posted on: December 17 2003 09:31 EST
- in response to vishal khatter
When you deploy an EJB to a server, you can assign its home interface any JNDI you like. This is a potential problem, because the JNDI name in production may be different from the one used in development.
<ejb-ref> allows you to define an "reference" JNDI name that is fixed. This "reference" JNDI name is mapped to the "real" JNDI name when you deploy it to production. This means you can safely use the "reference" JNDI in your code. That is the theory, anyway.
Personally, I just come up with a decent naming scheme for the "real" JNDI names and use those for both development and production. -
ejb-ref tag[ Go to top ]
- Posted by: vishal khatter
- Posted on: December 17 2003 09:51 EST
- in response to Paul Strack
Does declaring ejb-ref tag itself means that bean is attched to that ref-name
or we need to do anything else when deploying the bean that is referred. -
ejb-ref tag[ Go to top ]
- Posted by: Paul Strack
- Posted on: December 17 2003 23:40 EST
- in response to vishal khatter
When you deploy the EJB, the ejb-ref name does need to be mapped to the "real" JNDI name. This has to be done in a server-specific way. This complicates deployment, and is the main reason I don't like or use this feature of EJBs. -
why to use java:comp/env/ejb/jndiname[ Go to top ]
- Posted by: vishal khatter
- Posted on: January 23 2004 00:15 EST
- in response to vishal khatter
What is the advantage of using java:comp/env/ejb/jndiname when we are calling one ejb from another ejb in the same container.
For using java:comp/env/ejb/name is it compuslory that both the beans have to be in the same jar file. -
why to use java:comp/env/ejb/jndiname[ Go to top ]
- Posted by: Andre Fernandes
- Posted on: January 23 2004 14:24 EST
- in response to vishal khatter
This is not correct. The "java:comp/env/..." prefix can be translated to the real JNDI name of an EJB anywhere else (another JAR or another EAR). You are not tied to the same JAR.
The "java:comp/env/..." has the following benefits:
1. The dependency of an external EJB isn't hidden inside an application - you are forced to declare an ejb-ref of ejb-local-ref in web.xml, and you are forced to bind this reference to a real JNDI name in a complementary descriptor (like jboss-web.xml in JBoss or weblogic.xml in WebLogic). Not hidden dependencies eases administration, or so I believe;
2. The hard-coded "java:comp/env/..." (and its ejb-ref in web.xml) is ALWAYS portable. A hard-coded real JNDI name may not be portable;
3. If the EJB has both local and remote interfaces, the ejb-local-ref is the only way your application can access its local interfaces in WebSphere (the real JNDI name always returns the remote home stub);
Have in mind that any ejb-ref or ejb-local-ref must be translated to real JNDI names by server-specific descriptors. If that bothers you, so use the real JNDI name - it works ok except in some cases on WebSphere.