We are trying to migrate from websphere application server to websphere liberty profile.
As part of POC we are deploying a sample war with an EJB inside it. We injected the EJB using @EJB inside a restful web service. While calling the web service liberty is throwing NPE. Then i tried using InitialContext to lookup the EJB and its working fine.
Below are the features i enabled
- Jaxrs 1.1
- Jdbc 4.0
- ejbLite 3.1
We are running liberty on java 1.6.
Below is some code snippet
@EJB(beanName="StudentServiceBean")
private StudentServiceBean service;
Inside web service method
service.getStudent(id); // NPE here
Ejb class
@Stateless(name="StudentServiceBean")
public class StudentServiceBean {}
I even tried using @EJB with lookup and then tried with simple @EJB becUse the EJB is a local EJB and packed inside the war module itself
P.S. I moved the ejb to an ejb module and packed the application as an ear and tried. Still the ejb is not getting injected into the web service.
Then i created a new ejb and injected the new ejb into the existing ejb. The new ejb is injected properly. I think there is some problem with servlet container and the ejb container.
I tried it on liberty woth jee7 features also but still i am facing the same problem.