Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HOW TO ACCESS EJB FORM CLIENT  RSS feed

 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to ejb i have deployed my EJB on web logic server
i have to call that . so how to do that when i compiled my servlet it gives error that cannot find symbol home interface
it is necessary to add home interface and remote interface on class path
tell me thank you
 
Murali gopal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the JNDI name to look up home interface . The code is given below for your reference. If you are new to EJB then study the Mastering EJB by Ed Roman. You can dowload this pdf for free in theServerside.com.

Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");

/*
* Obtain the JNDI initial context.
*
* The initial context is a starting point for
* connecting to a JNDI tree. We choose our JNDI
* driver, the network location of the server, etc
* by passing in the environment properties.
*/
Context ctx = new InitialContext(h);

/*
* Get a reference to the home object - the
* factory for Hello EJB Objects
*/
Object obj = ctx.lookup("HelloHome");


/*
* Home objects are RMI-IIOP objects, and so
* they must be cast into RMI-IIOP objects
* using a special RMI-IIOP cast.
*
* See Appendix X for more details on this.
*/
HelloHome home = (HelloHome)
javax.rmi.PortableRemoteObject.narrow(
obj, HelloHome.class);

/*
* Use the factory to create the Hello EJB Object
*/
Hello hello = home.create();
System.out.println(hello.hello());
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!