Skip to main content

Glassfish application-name and JNDI

6 replies [Last post]
ossaert
Offline
Joined: 2007-03-09
Points: 0

Hi, when I add the element "application-name" to my application.xml, the beans are bound to JNDI with the wrong name. They still have the name of the EAR-file and NOT of the value in the application-name. Did I overlook something? Greetings, Jan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
feichtegger
Offline
Joined: 2009-06-25
Points: 0

I think the problem is/was that the field application name at glassfish's admin console will be set to the name of the ear-file and this name will be used as application name. If you deploy using the asadmin deploy command the name from application.xml will be used.

kind regard
michael

pbenedict
Offline
Joined: 2012-06-01
Points: 0

I have this identical problem using 3.1.2. Any solution? I deployed through the Admin Console and is just ignored.

ossaert
Offline
Joined: 2007-03-09
Points: 0

I use the following application.xml:



4eo-babylon
4eo-babylon-application


4eo-babylon-admin-war.war
4eo-babylon-admin-war



4eo-babylon-core-ejb.jar

The JNDI binding is mapped to EAR filename. So in java:global is the name of the EAR file and then the modules. I could change of the modules - that functions correctly. Unfortunately, a call to the java:app and java:module alwyas throws a NamingException since they do not exist (at first sight). I look into the InitialContext and see only java:global.

Why is this so? Where is the java:app and java:module?

Greetings
Jan

hzhang_jn
Offline
Joined: 2005-07-22
Points: 0

Your application.xml looks fine to me. But I tried a small test case from my side and seems things are working as expected for me. I have a simple ear which contains a war and an ejb jar.

I first deployed it without using the application-name element, and the application was deployed under the default name (ear name minus suffix), and the portable JNDI name for ejb seems to using that name:

$ asadmin deploy ~/deployment/apps/stateless-simple.ear
Application deployed successfully with name stateless-simple.

In the server.log: #|2010-02-17T09:47:10.740-0500|INFO|glassfishv3.0|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=23;_ThreadName=Thread-1;|Portable JNDI names for EJB TheGreeter : [java:global/stateless-simple/stateless-simpleEjb/TheGreeter, java:global/stateless-simple/stateless-simpleEjb/TheGreeter!samples.ejb.stateless.simple.ejb.GreeterHome]|#]

Then I edited the application.xml use the "foo" for application-name, now:
$ asadmin deploy ~/deployment/apps/stateless-simple-app-name.ear
Application deployed successfully with name foo.

The application is deployed under the name "foo".

And in the server.log, I got this for EJB JNDI name now:
[#|2010-02-17T09:47:48.530-0500|INFO|glassfishv3.0|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=24;_ThreadName=Thread-1;|Portable JNDI names for EJB TheGreeter : [java:global/foo/stateless-simpleEjb/TheGreeter!samples.ejb.stateless.simple.ejb.GreeterHome, java:global/foo/stateless-simpleEjb/TheGreeter]|#]

Can you check what name the application is deployed with in your case (check the statement "Application deployed successfully with name XXX") and also the server.log for the portable JNDI name print out?

hzhang_jn
Offline
Joined: 2005-07-22
Points: 0

No, the application-name when specified should be used as the application name.

When the application is deployed, you will see a message like this:
Application deployed successfully with name xxx

What's the "xxx" for your application, does it say the ear name or application-name specified in the application.xml?

Can you share your application or application.xml?

feichtegger
Offline
Joined: 2009-06-25
Points: 0

If you deploy your application using the admin console you have to specify the application name in the according field. After selecting an EAR file the name of the file without the prefix will be placed in that field.
If you do not set the value, the default value overrides the setting at application.xml.

If you use the asadmin deploy command everything works fine.