In EJB 3.1 JNDI Lookups can be made with different Lookup-Names:
java:global[/]//!
The application name and module names can be looked up at runtime via JNDI:
@Resource(lookup = "java:app/AppName")
private String appName;
@Resource(lookup = "java:module/ModuleName")
private String moduleName;
Although you can configure the application-name and module-name in your application deployment descriptor as described, these names can still be overridden at deployment-time (per the Java EE specification, as indicated below), so it's best not to hard-code these values in your application code.
EE.8.5.2 Deploying a Java EE Application and EE.8.5.1 Deploying a Stand-Alone Java EE Module
The deployment tool must ensure that the application name is unique in the application server instance. If the name is not unique, the deployment tool may automatically choose a unique name or allow the Deployer to choose a unique name
EE.8.1.1 Component Creation
If and only if the name is not unique (e.g., because two names are identical after removing different filename extensions) the deployment tool may choose new unique names for any of the conflicting modules; module names that do not conflict must not be changed. The algorithm for choosing unique names in such a case is product specific.