users@glassfish.java.net

Global JNDI naming bug?

From: Major Péter <majorpetya_at_sch.bme.hu>
Date: Sat, 19 Jun 2010 01:21:28 +0200

Hi all,

I'm trying to use the embedded glassfish server for my maven tests with
the following code:
Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(EJBContainer.MODULES, new
File("../sch-kp-ejb-impl/target/classes"));
        properties.put(EJBContainer.APP_NAME, "korok");
properties.put("org.glassfish.ejb.embedded.glassfish.installation.root",
"/home/user/glassfishv3-emb");
        EJBContainer ejb = EJBContainer.createEJBContainer(properties);

When the tests are running I can see in the log files:
INFO: Portable JNDI names for EJB UserManagerBean :
[java:global/korok/UserManagerBean,
java:global/korok/UserManagerBean!hu.sch.services.UserManagerLocal]

Quote from the EJB 3.1. specs, 4.4.1.1.1:
javax.ejb.embeddable.appName
This property specifies an application name for the EJB modules
executing within the embeddable container. If specified, the property
value applies to the <app-name> portion of the portable global JNDI name
syntax. It is recommended that this property be set whenever an
embeddable container is executed with more than one ejb module.

But when you check 4.4.1:
Each portable session bean global JNDI name has the following syntax :
java:global[/<app-name>]/<module-name>/<bean-name>[!<fully-quali-
fied-interface-name>]
<app-name> only applies if the session bean is packaged within an .ear
file. It defaults to the base name of the .ear file with no filename
extension, unless specified by the application.xml deployment descriptor.
<module-name> is the name of the module in which the session bean is
packaged. In a stand-alone ejb-jar file or .war file, the <module-name>
defaults to the base name of the module with any filename extension
removed. In an ear file, the <module-name> defaults to the pathname of
the module with any filename extension removed, but with any directory
names included. The default <module-name> can be overriden using the
module-name element of ejb-jar.xml (for ejb-jar files) or web.xml (for
.war files).

Okay, so the app-name is optional, but if I supplied explicitly the
application name, then why doesn't that appear in the Global JNDI
name??? The name of the EJB module is also 'korok', so I would like to
see 'java:global/korok/korok/UserManagerBean', but I'm not. What am I
missing?

Also when I deploy my application to a standalone GF, then the
application name is what I supplied in the asadmin --name parameter, but
based on 4.4.1 it should had been taken from application.xml or it
should be the name of the ear...

Regards,
Peter