Glassfish 4: how to set the name of the application or module for JNDI

I use EJB inside OSGi packages. And now, when I need to get EJB, I have a long jndi, for example:

bean = (InterfaceName) ctx.lookup("java:global/longBundleName_version/OrganizationDirBean!and.plus.path.and.InterfaceName"); 

I want to change this part:

 longBundleName_version 

I mean, when I deploy the package, this part should be installed from [glassfish-] application.xml or from [glassfish -] - ejb-jar.xml or from any other xml descriptor. I want the jndi name for my ejb to be:

 java:global/newBundleNameWithoutVersion/etc 

The problem is that I cannot find what I have to install in these files. All the options that I found on the Internet are no longer supported, and everything that I tried on my own does not work. could you help me?

Please do not suggest mappedName as it can only be used (!) For remote beans. I use beans that are both local and remote.

If someone is involved in the development of glass fish, could you at least indicate which beams I should study to find the question myself? I'll be very grateful.

+8
java java-ee glassfish glassfish-4 jndi
source share
1 answer

You should annotate your EJB as follows:

 @Remote(value = YourInterface.class) @Stateless(mappedName = "java:global/fancy") 

After that, GF logs says:

 EJB5182:Glassfish-specific (Non-portable) JNDI names for EJB YourInterfaceImpl: [java:global/fancy, java:global/fancy!com.example.YourInterface]]] 

And at least I managed to enter:

 <!-- language:java --> @EJB(lookup="java:global/fancy") 

Therefore, I believe that manual search should also work.

+3
source share

All Articles