complex
Adicionei as propriedades que encontrei no site do glassfish
https://glassfish.dev.java.net/javaee5/security/faq.html e agora está dando o seguinte erro
Failed to load com.sun.enterprise.naming.SerialInitContextFactory using CommonClassLoader
Sem as propriedades ele realiza o lookup porém getContext().getCallerPrincipal().getName() retorna branco
ps.
estou usando Custom login module
com.sun.appserv.security.AppservPasswordLoginModule
public static <T> T lookup(Class<T> ejbInterface) {
if (ejbInterface == null) {
throw new IllegalArgumentException("No EJBInterface specified");
}
try {
Properties properties = new Properties();
properties.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
properties.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
properties.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
properties.setProperty("org.omg.CORBA.ORBInitialHost", host);
properties.setProperty("org.omg.CORBA.ORBInitialPort", port);
Object bean = context.lookup(getJndi(ejbInterface));
return ejbInterface.cast(PortableRemoteObject.narrow(bean, ejbInterface));
} catch (NamingException e) {
throw new IllegalStateException("Cannot connect to bean: " + ejbInterface.getName() + " Reason: " + e,
e.getCause());
} finally {
try {
context.close();
properties = null;
} catch (NamingException ex) {
throw new IllegalStateException("Cannot close InitialContext. Reason: " + ex, ex.getCause());
}
}
}