• 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

Local Interfaces in EJB

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I understand that if the Session bean and the Entity are sitting on the same JVM, I can use the Local Interfaces.
And I cannot call the Local EJB from a Plain Java class. The calling unit should also be an EJB.

My question is that why am I not able to do this? Why I cant call Local Entity bean from a plain java class? Why I can only do it from another EJB?

Thanks,
Prashant
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Prashant,
Since normal Java architecture is not scatter for different OS. But you mgiht ask then how it is platform in-dependant, Of-course while installing you will take different version of Java for Win / Unix, right? So you might got ht point. But EJB Architecture is for distributes which can work even component in different platforem using RMI-IIOP protocol.
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You s'd not have any trouble calling a local ejb from within a java class as long as they are in the same VM.

You can easily test it.Write a simple servlet and a local ejb. Access the ejb from within the servlet.
Deploy this ear and invoke the servlet using the mapped URL.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To answer the original question: all local component interfaces (EJBs) can be used by any Java component capable of resolving its home interface and instantiating it via JNDI, as long as it is within the same address space. So, to correct you, plain ol' java class can use EJBs. Anything can, provided it's in the same address space as the application server hosting the EJBs.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can't find local home interface from servlet too.

ejb-jar.xml:
<ejb-name>TestEJB</ejb-name>
<local-home>study.tuncan.ejb.TestLocalHome</local-home>
<local>study.tuncan.ejb.TestHelloLocal</local>
<ejb-class>study.tuncan.ejb.TestBean</ejb-class>
<session-type>Stateless</session-type>

weblogic-ejb-jar.xml:
<ejb-name>TestEJB</ejb-name>
<local-jndi-name>TestLocalHome</local-jndi-name>
code in the servlet:
Context ctx = new InitialContext();
Object obj = ctx.lookup("TestLocalHome");

errors:
javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: While trying to look up /app/ejb/Test.jar#TestEJB/local-home in /app/webapp/studywebapp/8624359.;
...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic