Spent half a day solving the problem of ejb client lookup in glassfish 4.
The bean:
@Stateless
@LocalBean
public class TestBean implements TestRemote{
@PersistenceContext(unitName = "testunit")
private EntityManager em;
public String sayHello() {return "hello";}
}
The remote business interface:
@javax.ejb.Remote
public interface TestRemote {
public String sayHello();
}
Client lookup code, tried the following variants (the client can be in another machine, but in this test they are running on the same machine):
new InitialContext().lookup("java:global/myproject/TestBean");
new InitialContext().lookup("java:global/myproject/TestRemote");
new InitialContext().lookup("TestRemote");
new InitialContext().lookup("TestBean");
new InitialContext().lookup(TestBean.class.getName());
The project is deployed as a war (myproject.war).