This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling EJB from client!!!  RSS feed

 
ganapathy gopinathan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Anyone plz help to understand, how to call an EJB from the client program.i am using weblogic8.1

Thank you
gopinathan
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you have all the deployment descriptors in place.

try this and see

TestHome = home interface
remote = remote interface
Test = JNDI NAME you have given in your deployment descriptor

InitialContext ic = new InitialContext();
TestHome testHome =
( TestHome ) PortableRemoteObject.narrow(
ic.lookup( "Test" ), TestHome.class );

remote = TestHome.create();

Once you have the Remote interface, you can call all the business methods available in Bean
 
ganapathy gopinathan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi mohen,

Thank you for your response
It worked!!!

regards
gopi
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also don't forget if you are calling these EJB's from within the same container that you should/could use the Local interfaces instead of the remote to improve on performance.
 
Ramya Dhurga
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
public class SessionClient
{
public static void main(String args[])
{
try
{
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx=new InitialContext(h);
Object obj=ctx.lookup("FirstBean");
SessionHome s=(SessionHome)PortableRemoteObject.narrow(obj, SessionHome.class);
SessionRemote r=s.create();
System.out.println(r.add(10,20));
}catch(Exception e){}
}
}
 
Alphanzox Alex
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey ramya,

could you please let me know what will the property values be for jboss 4.

Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!