Skip to content

Instantly share code, notes, and snippets.

@kamcpp
Created November 2, 2014 09:33
Show Gist options
  • Select an option

  • Save kamcpp/981f65cfb4a0abf6865e to your computer and use it in GitHub Desktop.

Select an option

Save kamcpp/981f65cfb4a0abf6865e to your computer and use it in GitHub Desktop.
TomEE-EJB-Remote-Invocation
import my_ejb_api.MyNumberGeneratorLocal;
import my_ejb_api.MyNumberGeneratorRemote;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;
public class Test {
public static void main(String[] args) throws NamingException {
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://localhost:8080/tomee/ejb");
InitialContext ctx = new InitialContext(p);
MyNumberGeneratorRemote myNumberGeneratorRemote = (MyNumberGeneratorRemote) ctx.lookup("RandomNumberGeneratorRemote");
System.out.println(myNumberGeneratorRemote.generateNumber());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment