What's the application server which you are using? Minimum things which you need to know before calling a client are:
1. The JNDI name of the ejb/home
2. The hostname/port of the server
These things are not seen in your code. The hostname/port depends on server to server.
For example:
for weblogic, following code would work:
public class Client
{
private static final String JNDI_NAME = "ejb20-greetingsBean-GreetingsHome";
private String url;
private GreetingsHome home;
public Client(String url) throws NamingException {
this.url = url;
home = lookupHome();
}
public static void main(String[] args) throws Exception {
log("\nBeginning greetingsBean.Client...\n");
String url = "t3://localhost:7001";
Client client = null;
// Parse the argument list
if (args.length != 1) {
log("Usage: java examples.ejb20.basic.greetingsBean.Client
t3://hostname 
ort");
return;
} else {
url = args[0];
}
try {
client = new Client(url);
client.example();
} catch (NamingException ne) {
log("Unable to look up the beans home: " + ne.getMessage());
throw ne;
} catch (Exception e) {
log("There was an exception while creating and using the Greetings.");
log("This indicates that there was a problem communicating with the server: "+e);
throw e;
}
log("\nEnd greetingsBean.Client...\n");
}
public void example()
throws CreateException, RemoteException, RemoveException
{
log("Creating the Greetings");
Greetings greetings = (Greetings) narrow(home.create(), Greetings.class);
System.out.println(greetings.getMessage());
log("Removing the greetings");
greetings.remove();
}
private Object narrow(Object ref, Class c) {
return PortableRemoteObject.narrow(ref, c);
}
private GreetingsHome lookupHome() throws NamingException {
// Lookup the beans home using JNDI
Context ctx = getInitialContext();
try {
Object home = ctx.lookup(JNDI_NAME);
return (GreetingsHome) narrow(home, GreetingsHome.class);
} catch (NamingException ne) {
log("The client was unable to lookup the EJBHome. Please make sure ");
log("that you have deployed the ejb with the JNDI name "+
JNDI_NAME+" on the WebLogic server at "+url);
throw ne;
}
}
private Context getInitialContext() throws NamingException {
try {
// Get an InitialContext
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
return new InitialContext(h);
} catch (NamingException ne) {
log("We were unable to get a connection to the WebLogic server at "+url);
log("Please make sure that the server is running.");
throw ne;
}
}
private static void log(String s) { System.out.println(s); }
}
HTH,
Kalyan