wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes How to get application ear file name using Java code for JNDI lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to get application ear file name using Java code for JNDI lookup" Watch "How to get application ear file name using Java code for JNDI lookup" New topic
Author

How to get application ear file name using Java code for JNDI lookup

Chandrasekaran Pethan
Greenhorn

Joined: Mar 06, 2012
Posts: 1
I have migrated an EAR application from Jboss 3 to JBoss 7. For JNDI lookups I am using the following syntax in JBoss AS 7.1 (as referred in https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI)

ejb:<app-name>/<module-name>/<distinct-name>/<bean-name>!<fully-qualified-classname-of-the-remote-interface>
where ->
app-name : This is the name of the .ear (without the .ear suffix)
module-name : This is the name of the .jar (without the .jar suffix)
distinct-name : This is a JBoss AS7 specific name which can be optionally assigned to the deployments that are deployed on the server
bean-name : This is the name of the bean for which you are doing the lookup
fully-qualified-classname-of-the-remote-interface : This is the fully qualified class name of the interface for which you are doing the lookup.

As of now I am hardcoding the app-name,module-name etc while doing JNDI lookup but I need to get in at runtime in case if I wish to override the ear name(deployment file placed at JBoss/deployment folder) using Command Line Interface

How to use javax.naming.InitialContext or ServeltContext or javax.naming.Context, I tried placing some property file and using these context files but I couldn't retrieve the application ear file name

Please advice.

Thanks in Advance.

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

It would be better to ask this in the JBoss forum, moving...


JBoss In Action
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

The remote client application needs to know the exact JNDI name. Of course, the application can use some kind of properties to be passed into the application to know the app name, module name etc... but that's up to the application and even in that case, the person who is triggering the application will have to know the app name, module name etc.. to be fed to the JNDI name.

[My Blog] [JavaRanch Journal]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get application ear file name using Java code for JNDI lookup