In EJB 3.1 JNDI Lookups can be made with different Lookup-Names:
java:global[/<app-name>]/<module-name>/<bean-name>!<fully-qualifiedbean interface-name>
java:global[/<app-name>]/<module-name>/<bean-name>
java:app/<module-name>/<bean-name>!<fully-qualified-bean-interface-name>
java:app/<module-name>/<bean-name>
java:module/<bean-name>!<fully-qualified-bean-interface-name>
java:module/<bean-name>
In my JavaEE 6 Project (with Maven 2, Netbeans 6 and Glassfish v3) the Application name is X-Snapshot.ear and the EJB-Module is Y-Snapshot.jar. How can i config this maven project to use another application and module name? I don't wnat to change all JNDI Lookups when this names change!! So is it possible to config application and module names for JNDI LookUps?
Naive approach
The Maven EAR Plugin allows to Customize A Module Filename and you can set the final name or the EAR using
project.build.finalName
.Much better approach
Override the
<application-name>
and the<module-name>
in theapplication.xml
and theejb-jar.xml
respectively. Quoting Portable Global JNDI name in EJB 3.1:The application name and module names can be looked up at runtime via JNDI:
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.