0

I have 2 EJB modules and I want to make communication between them.

  1. EJB module has EB (Entity Bean) and SB (Stateless Sesssion Bean) (With Local Facades)
  2. EJB module has a simple public class Test which uses local facade (MyairportsFacadeLocal) from the first module.
public class Test {  
    @EJB
    MyairportsFacadeLocal myafl;

    public Test(){
         int rowsCount=myafl.count();
    }
} 

When I run the code above, I get an error (title). Unsuccessful deployment.

Also, I tried with @Inject. With that annotation, app starts successfully but myafl is null... Everything works fine when @EJB is inside of the bean, but I don't know how to communicate with first EJB module when I need communication outside of the bean.

Domagoj Hamzic
  • 300
  • 3
  • 17
  • 1
    If I understand you correctly, you have two EJB modules (two separates JAR) deployed on app server and when you call EJB from first JAR to second JAR your injection point is empty? – Petr Freiberg Jun 14 '20 at 16:07
  • 1
    @PetrFreiberg That's right. – Domagoj Hamzic Jun 14 '20 at 20:39
  • 1
    Both JARs are deployed separately. I think injection from JAR 1 simply didn’t see classes from JAR 2. I would try to use only manual JNDI lookup via @Produces. Method with Produces annotation is used every time when you need the type which returning (via Injection). You can have only one method for one type otherwise error will be thrown during deployment phase. – Petr Freiberg Jun 15 '20 at 07:12
  • 1
    I detail explained it here: https://java.pfreiberg.cz/injecting-ejbs-from-jar-to-war-using-cdi please look. – Petr Freiberg Jun 15 '20 at 07:12

0 Answers0