• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can we access the Bean with local interface inside client in same package as bean?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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???

Thanx in advance.

Prash
 
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it is not true. The local interface can be used by clients running in the same EJB container and same Java virtual machine. Clients not only include EJBs but also other co located Java classes.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

normal java client


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 ]
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Prashant,

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.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Now can I access the Bean in this client?

Pls tell me.
Thanx.
Prash
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 tiwari_p_k@yahoo.com
Thanx.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic