1

I've got an EJB set up in my entity-layer-EAR:

    <session>
        <ejb-name>DoctorDaoImpl</ejb-name>
        <business-local>mypath.DoctorDao</business-local>
        <ejb-class>mypath.DoctorDaoImpl</ejb-class>
        <session-type>Stateless</session-type>
    </session>

According to the logs, the EAR and its EJBs start up fine. I have the facade (e.g. DoctorDao) in shared libs, and the entity layer EAR has the implementations (eg. DoctorDaoImpl).

Now when I deploy my Doctor service, it has a data-service.jar who's DoctorDataEjb injects DoctorDao.

But I get an error saying:

The mypath.DoctorDao EJB reference in the DoctorDataEjb component in the data-service.jar module of the Doctor application could not be resolved. nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface mypath.DoctorDao not present in application Doctor

Now, I realise that indeed, the EJB is not present in the Doctor application. It is present in the entity-layer-EAR. I've seen this link which is similar, so I imagine I must just work out the correct binding-name to enter in the "EJB references" WAS Admin UI (or perhaps I can set it in ibm-ejb-jar-bnd.xml).

If I look at the generated ejb-jar_merged.xml, I see the ref defined as such:

<ejb-ref>
     <ejb-ref-name>mypath.DoctorDao</ejb-ref-name>
     <remote>mypath.DoctorDao</remote>
     <injection-target>
        <injection-target-class>mypath.DoctorDataEjb</injection-target-class>
        <injection-target-name>doctorDao</injection-target-name>
     </injection-target>
</ejb-ref>

I tried setting the Target Resource JNDI Name to: java:global/MyEntityLayerApp/entity-service/DoctorDaoImpl!myPath.DoctorDao and now get: java.lang.IllegalArgumentException: Can not set myPath.DoctorDao field myPath.DoctorDataEjb.doctorDao to myPath.EJSLocal0SLDoctorDaoImpl_

zoiks. Something about 'Local'.

Community
  • 1
  • 1
djb
  • 1,635
  • 3
  • 26
  • 49

1 Answers1

2

It looks like you're defining a local ejb interface:

 <ejb-name>DoctorDaoImpl</ejb-name>
    <business-local>mypath.DoctorDao</business-local>

and than you try to reference it as a remote:

<ejb-ref>
 <ejb-ref-name>mypath.DoctorDao</ejb-ref-name>
 <remote>mypath.DoctorDao</remote>

It won't work. You'll have to decide which fits your business case :)

groo
  • 4,213
  • 6
  • 45
  • 69
  • Thanks Marcos, what a doozy. interface Dao has the methods and is Local, then DaoRemote (extends Dao) is empty and Remote, and then all our EJBs extend DaoRemote. So I thought DoctorDao would inherit the Remote, but I guess it is actually Local. But the ejb-jar_merged I pasted is generated by WAS. So it clearly things DoctorDao is Local. Let me see if changing this (to a common base Dao with one Local and one Remote extension) helps. – djb May 09 '13 at 08:20
  • It still doesn't work, so we're going to try directly referencing named ejbs. I think we're just going to sidestep this whole EJB-in-another-EAR business if we can. Just cut up the entity layer into one EJB per EAR. – djb May 09 '13 at 09:24
  • Ok, so the only way I was able to get it to work was to name the EJB in the WAS UI, and then map to that name in UI for the other service. It seems archaic. There seems to be no other way. Correct me if I'm wrong. So we're going to have to refactor everything :/ – djb May 09 '13 at 13:19
  • Is this an ejb 3? Did you implemented it as local or remote? – groo May 09 '13 at 16:12