Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local Interfaces in EJB

 
Prashant Satarkar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Natarajan Shankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • 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.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • 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.
 
Stephen Tong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.;
...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic