我有同样的EJB模块,在服务器端的EAR和客户端的EAR里面有一个Bean,我可以有这种情况吗?
因为我得到了这个错误 http:/justpaste.itgfs3却不知道如何解决。
你在堆栈跟踪中有答案。
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.]
如果你问的是你是否可以在多个项目中使用相同的EJB jar,答案是可以的。但是在部署过程中,你必须使用长格式的JNDI,为其他模块中的Bean提供不同的JNDI名称或者禁用短名称。你不能在同一个名字下注册两个bean。
长名的形式是 RitornaPersonaSenzaClientEAR#RitornaPersonaSenzaClient.jar#com.demo.view.RitornaPersonaRemote
在这里查看详细信息 - EJB 3.0和EJB 3.1应用绑定概述
更新
要禁用短名,请执行以下步骤。
Application servers > server1 > Process definition > Java Virtual Machine > Custom properties
com.ibm.websphere.ejbcontainer.disableShortDefaultBindings
有价值 *
禁用所有应用程序的短绑定或 AppName1|AppName2
来禁用选定应用程序中的短绑定。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
而使用 disableShortDefaultBindings
属性集没有简式。
The binding location is: ejblocal:JPADepEar/JPADepEJB.jar/TableTester#ejb.TableTester
The binding location is: java:global/JPADepEar/JPADepEJB/TableTester!ejb.TableTester
文件中存在一个错误,正确的属性是: com.ibm.websphere.ejbcontainer.disableShortDefaultBindings. 不 com.ibm.websphere.ejbcontainer.disableShortFormBinding.
在我的例子中:- 我安装了abc.ear和xyz.ear,这两个ear都是独立的,相互之间有依赖性。
我使用客户端查找调用abc.ear,但这给我带来的是
com.ibm.websphere.naming.CannotInstantiateObjectException.JNDI NamingManager在处理javax.naming.Reference对象时发生异常。当JNDI NamingManager处理一个javax.naming.Reference对象时发生了异常。[根异常是com.ibm.websphere.ejbcontainer.AmbiguousEJBReferenceException。短式默认绑定'com.ejb.abc'是含糊的,因为多个bean实现了接口:[xyz-ear#rabc-ejb-1.0.jar#abcInrerfaceImpl, rabc-ear#rabc-ejb-1.0.jar]。
我的解决方案是:-
我删除了另一个应用程序(xyz.ear)里面的abc.jar,C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\wstemp\92668751\workspace\cells\mypc00Node01Cell/applications\xyz-ear.ear' 。
然后,解决方案的客户端查询工作正常。
为了避免这种情况发生,最好的做法是在你的IBM-WAS服务器上创建单独的节点,并将两个应用程序安装在不同的节点上。
这样两个应用组件就不会出现混乱。