Skip to content

Instantly share code, notes, and snippets.

@lcruz
Created March 22, 2013 17:01
Show Gist options
  • Save lcruz/5222977 to your computer and use it in GitHub Desktop.
Save lcruz/5222977 to your computer and use it in GitHub Desktop.
Calling an EJB from single program in Java
private EJBInterface getEJB() {
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://host:port");
Context context;
try {
context = new InitialContext(h);
EJBHome home =
(EJBHome) context.lookup("<jndi_name>");
return home.create();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment