ejbejb-3.0jndiwebsphere-7

Same stateless bean in two ears


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.


Solution

  • 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:

    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