1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.swing.JOptionPane;
import packageApp.SessionBeanSingletonInterface;
.....
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// glassfish default port value will be 3700,
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx;
try {
ctx = new InitialContext(props);
SessionBeanSingletonInterface bean = (SessionBeanSingletonInterface) ctx.lookup("packageApp.SessionBeanSingletonInterface");
System.out.println(bean.getMessage());
} catch (NamingException ex) {
Logger.getLogger(JavaApplicationUsingEJB.class.getName()).log(Level.SEVERE, null, ex);
} |
Partager