I have heard that we can only access bean locally through other beans inside same container & we can not access bean trough local interface from normal java client though client will be in same package as that of bean. Is this true???
If this is a standalone java client you *will have to* use remote interfaces, since this standalone class will be using its own JVM. You *cant* use local interfaces in this case [ February 15, 2006: Message edited by: jaikiran pai ]
My reply is based on the assumption that normal java client though client will be in same package as that of bean refers to a Java class containing the code to create instance of Context (or InitialContext) and doing a lookup with the Local EJB JNDI name.
A local client must be in the same application as the EJB it is calling. This means that the client must be packaged in the same EAR file or exploded directory as the EJB.
If the client and EJB are in different applications, let us say different EAR files, then the client must be remote even if both apps are deployed to the same server instance.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Joined: Nov 07, 2005
Hi, This is my directory structure for EJB:- ======== CartMasterBean.java -- Bean Implementation class CartMaster.java -- Bean Remote class CartMasterLocal.java -- Bean Local Remote class CartMasterLocalHome.java -- Bean Home class CartMasterHome.java -- Bean Remote Home class Client.java --------Simple Java Program (Client) Accessing Bean through Local Home Interface as follow "CartMasterLocalHome cm=(CartMasterLocalHome)initialcontext.lookup("CartMasterLocal")" ========
Here "CartMasterLocal" is the local JNDI name for EJB.
I think you mix things up here. As someone already pointed out a local interface can only accessed by a class within the same application (JAR or EAR). A local interface does not have the means to be invoked remotely but also class loading issues prevent you from accessing the local interface from another application (JAR/EAR) because these two applications are loaded by different class loaders. This means that even when your client in another application does have the local interface the class obtained from the JNDI service is different from the one locally and you will end up in a Class Cast Exception.
Joined: Nov 07, 2005
HI Andreas ,
Thanx for ur reply. I got my mistake. I would like to have ur mail ID in my mail list. If u dont mind then give me ur id. My id is firstname.lastname@example.org Thanx.