在两只耳朵中的无国籍豆 [英] Same stateless bean in two ears

查看:149
本文介绍了在两只耳朵中的无国籍豆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EJB模块,在一个服务器端的EAR内部有一个bean,一个是客户端的EAR。
我可以有这种情况吗?





由于我收到此错误 http://justpaste.it/gfs3
没有理解如何解决它。

解决方案

你有堆栈跟踪中的答案:

 短格式默认绑定'com.demo.view.RitornaPersonaRemote'
是不明确的,因为多个bean实现了接口:
[ RitornaPersonaSenzaClientEAR#RitornaPersonaSenzaClient.jar#RitornaPersona,
RitornaPersonaWebSenzaClientEAR#RitornaPersonaSenzaClient.jar#RitornaPersona]。
提供一个特定于接口的绑定或使用查询上的长格式默认绑定。]

如果您询问您是否可以在多个项目中使用相同的EJB jar,那么答案是可以的。但是在部署期间,您必须使用长格式的JNDI,为其他模块中的bean提供不同的JNDI名称或禁用短名称。您不能以同名的方式注册两个bean。



长名称的格式为 RitornaPersonaSenzaClientEAR#RitornaPersonaSenzaClient.jar#com.demo.view.RitornaPersonaRemote



请参阅这里的详细信息 - EJB 3.0和EJB 3.1应用程序绑定概述



更新



要禁用短名称执行以下步骤:




  • 转到应用服务器> server1>流程定义> Java虚拟机>定制属性

  • 定义新的自定义属性 com.ibm.websphere.ejbcontainer.disableShortDefaultBindings ,值 * 可以禁用所有应用程序的短绑定,或者禁用 AppName1 | AppName2 在所选应用程序中禁用短绑定。



示例默认绑定显示在SystemOut.log中:

 绑定位置是:ejblocal:JPADepEar / JPADepEJB.jar / TableTester#ejb.TableTester 
绑定位置是:ejblocal:ejb.TableTester
绑定位置是:java:global / JPADepEar / JPADepEJB /TableTester!ejb.TableTester

disableShortDefaultBindings 属性集没有简短的形式:

 绑定位置是:ejblocal:JPADepEar / JPADepEJB.jar / TableTester#ejb。 TableTester 
绑定位置是:java:global / JPADepEar / JPADepEJB / TableTester!ejb.TableTester

有一个错误在文档中和正确的属性是 com.ibm.websphere.ejbcontainer.disableShortDefaultBindings 不是 com.ibm.websphere.ejbcontainer.disableShortFormBinding


I have the same EJB module with a bean inside an EAR that is server side and an EAR that is the client side. Can I have this situation?

Because I'm getting this error http://justpaste.it/gfs3 without understand how to fix it.

解决方案

You have answer in the stack trace:

The short-form default binding 'com.demo.view.RitornaPersonaRemote' 
is ambiguous because multiple beans implement the interface : 
[RitornaPersonaSenzaClientEAR#RitornaPersonaSenzaClient.jar#RitornaPersona, 
RitornaPersonaWebSenzaClientEAR#RitornaPersonaSenzaClient.jar#RitornaPersona]. 
Provide an interface specific binding or use the long-form default binding on lookup.]

If you are asking whether you may have same EJB jar in multiple project - the answer is yes you can. However during deployment you have to use long-form JNDI, provide different JNDI name for beans in other module or disable short names. You cannot register two beans under same name.

Long name would be in the form RitornaPersonaSenzaClientEAR#RitornaPersonaSenzaClient.jar#com.demo.view.RitornaPersonaRemote

See detailed info here - EJB 3.0 and EJB 3.1 application bindings overview

UPDATE

To disable short names perform the following steps:

  • Go to Application servers > server1 > Process definition > Java Virtual Machine > Custom properties
  • Define new custom property com.ibm.websphere.ejbcontainer.disableShortDefaultBindings with value * to disable short bindings for all apps or AppName1|AppName2 to just disable short bindings in selected apps.

Example default bindings are shown in SystemOut.log:

The binding location is: ejblocal:JPADepEar/JPADepEJB.jar/TableTester#ejb.TableTester
The binding location is: ejblocal:ejb.TableTester
The binding location is: java:global/JPADepEar/JPADepEJB/TableTester!ejb.TableTester

And with disableShortDefaultBindings property set there is no short form:

The binding location is: ejblocal:JPADepEar/JPADepEJB.jar/TableTester#ejb.TableTester
The binding location is: java:global/JPADepEar/JPADepEJB/TableTester!ejb.TableTester

There is a bug in the documentation and the correct property is com.ibm.websphere.ejbcontainer.disableShortDefaultBindings not com.ibm.websphere.ejbcontainer.disableShortFormBinding

这篇关于在两只耳朵中的无国籍豆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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