Glassfish 4:如何为JNDI设置应用程序或模块名称 [英] Glassfish 4: how to set application or module name for JNDI

查看:118
本文介绍了Glassfish 4:如何为JNDI设置应用程序或模块名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OSGi包内使用EJB。现在,当我需要获取EJB时,我有很长的jndi,例如:

  bean =(InterfaceName)ctx.lookup( Java的:全球/ longBundleName_version / OrganizationDirBean and.plus.path.and.InterfaceName!); 

我想改变这部分:

  longBundleName_version 

我的意思是,从[glassfish-] application.xml或从[glassfish - ] - ejb-jar.xml或从任何其他xml描述符设置。我想让我的ejb的jndi名称如下所示:

  java:global / newBundleNameWithoutVersion / etc 

我无法找到必须在这些文件中设置的问题。我在互联网上找到的所有变体都不再受支持,我自己尝试的所有功能都无法使用。你能帮我吗?



请不要提供mappedName,因为它只能用于远程bean(!)。我确实使用同时在本地和远程的bean。


如果某人参与了glassfish的开发,您能否至少指出我必须包含哪些bundle检查自己找到问题?我将非常感激。 即:


$ b

  @Remote(value = YourInterface.class)
@Stateless( )

之后, GF logs说:

  EJB5182:EJB的Glassfish特定(不可移植)JNDI名称YourInterfaceImpl:[ java:global / fancy,java:global / fancy!com.example.YourInterface]]] 

至少我能够注入像:

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

因此,我认为手动查找也应该有效。

I use EJB inside OSGi bundles. And now when I need to get EJB I have 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 bundle this part must be set from [glassfish-]application.xml or from [glassfish-]-ejb-jar.xml or from any other xml descriptor. I want jndi name for my ejb to be like:

java:global/newBundleNameWithoutVersion/etc

The problem that I can't find what I must set in these files. All variants I found in internet are not supported anymore and all I tried myself didn't work. Could you help me?

Please, don't offer mappedName as it can be used only(!) for remote beans. I do use beans which are at the same time both local and remote.

If someone is involved in glassfish development, could you at least point what bundles I must examine to find the question by myself? I will be very grateful.

解决方案

You should annotate your EJB like that:

@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 was able to inject like:

<!-- language:java -->

@EJB(lookup="java:global/fancy")

So I think manual look up should also work.

这篇关于Glassfish 4:如何为JNDI设置应用程序或模块名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆