I am not sure if this is true for Glassfish or not, but in case of JBOSS, if you turn on DEBUG, you can notice the jndi name that would be used.
For example, during the deployment of a session bean named DemoBean, you will see the following log in the server.log file:-
2009-07-24 09:08:18,747 DEBUG [org.jboss.ejb3.stateless.StatelessDelegateWrapper] Creating jboss.j2ee:jar=SessionBeanDemo.jar,name=DemoBean,service=EJB3
2009-07-24 09:08:18,747 DEBUG [org.jboss.ejb3.ProxyDeployer] no declared remote bindings for : DemoBean
2009-07-24 09:08:18,747 DEBUG [org.jboss.ejb3.ProxyDeployer] there is remote interfaces for DemoBean
2009-07-24 09:08:18,747 DEBUG [org.jboss.ejb3.ProxyDeployer] default remote binding has jndiName of DemoBean/remote
Then in your client code you can look it up like this:-
InitialContext ctx;
try {
ctx = new InitialContext();
DemoBeanRemote demo = (DemoBeanRemote) ctx.lookup("DemoBean/remote");
System.out.println(demo.sayHello());
} catch (NamingException e) {
e.printStackTrace();
}