File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Writing a remote client to access EJBs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Writing a remote client to access EJBs" Watch "Writing a remote client to access EJBs" New topic

Writing a remote client to access EJBs

dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Hi all,
I am a fairly experienced Java developer, but am new to EJBs. I've gone through some books and tutorials, and I think I basically understand how to write EJB server components. All of the sample applications that I wrote run fine.
Problem is, the client and server code of these sample apps all run on the same machine; the same JVM as well. What I am trying to do is write a separate, totally simple, Java app to run from the command line from another computer, separate from where the EJB container is running (I would access the server machine from the client machine over my home DSL hub.)
So my (hopefully simple) question is... what do I need for the client app? Do I need certain JAR files for it to run? I assume it needs the JNDI classes, but does it need any EJB-specific classes as well? How about my custom Enterprise Java Bean... do I need to copy over any of my own code for the client to use? Presumably the client would need the home and remote interfaces in its classpath, else it couldn't compile, but does it need any other of my code?
Presumably this is done all the time with EJBs, so hopefully someone knows the answer!
Thanks in advance!

Dave Taubler<br />Specializing in <a href="" target="_blank" rel="nofollow">Java and Web Development</a>
Torsten Schippel
Ranch Hand

Joined: May 09, 2003
Posts: 62
Hi Dave,
how to package your client you can find in the
Sun Tutorial.
Additional you need to set some properties to find your remote server.
Properties props= new Properties();
props.put( Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); //for JBoss Client
props.put(Context.PROVIDER_URL,"Server ort");
The Factory depends on your application server e.g.
BEA weblogic.jndi.WLInitialContextFactory
JBoss org.jnp.interfaces.NamingContextFactory
Additional you need some server dependent other jars (which should include JNDI).
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 364
You will need to make sure your client has access to the Remote/Home Interfaces.

No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Okay, thanks both for replying.
It looks like part of what I need to do is figure out what classes/JARs Orion itself requires its clients to have, at least for the JNDI and EJB-specific functionality.
William, are you saying that I should copy over the actual compiled home/remote interfaces that I write & compile myself?
I agree. Here's the link:
subject: Writing a remote client to access EJBs
It's not a secret anymore!