Search code examples
jbossejbjava-ee-6ejb-3.1jboss-eap-6

overriding JNDI names in JBoss EJB3.1


We're using Maven and Artifactory, and therefore our ear files have names like

 our-project-ear-0.0.1-20151215.151526-3.ear. 

So JNDI names for our EJBs have names like

java:global/our-project-ear/our-project-ejb/AnEjbJar!com.acme.ourproject.SomeEjb.

These names are not just ugly and complex, they also embed temporary suffixes added by Maven/Artifactory.

I thought we could simplify the names via the JBoss-specific @RemoteHomeBinding annotation, but I do not find this annotation in EAP 6.3. Is there still a way to do this? If not, how can I control the JNDI name under which my EJBs are published?


Solution

  • Figured it out myself. The @RemoteBinding, @LocalBinding, @RemoteHomeBinding and @LocalHomeBinding annotations have been phased out in AS7.x. A version of the JBoss instructions for migrating from AS5/6 to AS7 (not the current one) states:

    >In AS7 there is no possibility for custom JNDI names of EJB beans and it's not planned for 7.1.
    
    >Therefor the annotation @RemoteBindings and @LocalBindings are not available.
    

    The recommended approach is to use the default bindings. However, custom JNDI names can also be defined via the @EJB annotation, as stated in this Oracle blog:

    The developer can select an additional JNDI name that resolves to a particular client view of a session bean by using the @EJB annotation. Starting with Java EE 6, the @EJB name() attribute value can be prefixed with any one of the three portable Java EE namespaces : java:global, java:app, java:module. This has the effect of exporting the dependency into the selected scope.