I am having some issues trying to inject a stateless EJB into an Application Client Project. Both the App Client and the EJB are in the same EAR. Using JNDI, I am able to retrieve an instance of the EJB, but I'm not sure how should I do it with the @EJB annotation. I've tried using @EJB(name="something"), @EJB(mappedName="something"), but all I get is a null. Here is my code:
@Remote
public interface TimerEjbTestService {
public void testMethod();
}
@Stateless(mappedName="TimerEjbTestService")
public class TimerEjbTestBean implements TimerEjbTestService{
public void testMethod() {
System.out.println("Inside EJB.");
}
}
With JNDI I'm able to get the instance as follows:
Context ctx = new InitialContext();
TimerEjbTestService timerEjbTestService = (TimerEjbTestService) ctx.lookup("TimerEjbTestService#myejb.timerejbtestservice.services.TimerEjbTestService");
Any ideas on how can I do this?