Wednesday, December 14, 2011

Remote EJB call in Glassfish

Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort","3700");

try
{
Context ic = new InitialContext(props);
ServiceRemote remote = (ServiceRemote ) ic
.lookup("aja/ServiceBean");
remote.lala();

}
catch (Exception e)
{

}

Create a stateless bean and do like this

@Stateless(mappedName="aja/ServiceBean")

public ServiceBean implements ServiceRemote

0 comments:

Post a Comment