0

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?

ERAs

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

TommyBs
  • 9,354
  • 4
  • 34
  • 65
DarkCoffee
  • 930
  • 3
  • 17
  • 30

2 Answers2

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

Gas
  • 17,601
  • 4
  • 46
  • 93
  • How can I change JNDI in websphere 7? I looked at this answer http://stackoverflow.com/questions/13738457/setting-up-a-url-resource-on-websphere-application-server-7-0 but nothing has changed – DarkCoffee Jul 31 '14 at 22:13
  • In application context I have – DarkCoffee Jul 31 '14 at 22:32
  • 1
    Thats fine, but in that case you need to disable short names using JVM custom property - `com.ibm.websphere.ejbcontainer.disableShortDefaultBindings` or define custom names for these beans either through `ibm-ejb-jar-bnd.xml` file or through admin console Applications > yourApp > Bind EJB business and then change the names in each application context. – Gas Aug 01 '14 at 00:03
  • Hence, you are saying that I have to create a new file called `ibm-ejb-jar-bnd.xml` and inserting ` `, am I right? I tried but I've got the same error, with also "RP". – DarkCoffee Aug 01 '14 at 09:11
  • I'd first try to disable short names via custom property and see if the error is gone. Should be easier and without any changes to your code. – Gas Aug 01 '14 at 10:21
  • I followed this guide http://www-01.ibm.com/support/knowledgecenter/SSAW57_6.1.0/com.ibm.websphere.nd.doc/info/ae/ae/xrun_jvm.html?cp=SSAW57_6.1.0%2F1-15-4-381&lang=en and this http://www-01.ibm.com/support/knowledgecenter/SSAW57_6.1.0/com.ibm.websphere.ejbfep.multiplatform.doc/info/ae/ae/cejb_bindingsejbfp.html?cp=SSAW57_6.1.0%2F5-1-4-1-4&lang=en but nothing – DarkCoffee Aug 01 '14 at 13:13
0

In my case:- i did install abc.ear and xyz.ear both ear was independent do dependency with each other.

I was calling abc.ear using client-lookup but that was giving me

com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.websphere.ejbcontainer.AmbiguousEJBReferenceException: The short-form default binding 'com.ejb.abc' is ambiguous because multiple beans implement the interface : [xyz-ear#rabc-ejb-1.0.jar#abcInrerfaceImpl, rabc-ear#rabc-ejb-1.0.jar

abcInrerfaceImpl]. Provide an interface specific binding or use the long-form default binding on lookup.]

my Solution was:-

i removed the abc.jar that was inside another application(xyz.ear) C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\wstemp\92668751\workspace\cells\mypc00Node01Cell\applications\xyz-ear.ear '

Then solution client-lookup works fine.

To avoid this in future this is better practice to create separate node on your IBM-WAS server and install both application on different node.

So both application component will not mess up.

Community
  • 1
  • 1
Vinit Bhardwaj
  • 173
  • 2
  • 5