Same stateless bean in two ears

无人久伴 提交于 2019-12-23 06:07:33

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/25062710/same-stateless-bean-in-two-ears

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!