my configuration is: JBoss Wildfly 8.0.0, EJB 3.0, Resteasy 3.0.6, EAR project with web, ejb, api modules.
I have a rest resource annotated with @Path in my web module:
@Path("/boxes")
@Produces(MediaType.APPLICATION_JSON)
@Stateless
public class BoxServiceResource {
@EJB
private IBoxService boxService;
@GET
@Path("/test")
@Produces("text/plain")
public String test() {
return "test string";
}
@GET
@Path("/list/{date}/{type}")
public List<BoxDTO> getBoxesForDate(@PathParam("date") String date,
@PathParam("type") DateType type) {
return boxService.getBoxesForDate(new Date(), DateType.DAY);
}
@GET
@Path("/byId/{id}")
public BoxDTO getBoxById(@PathParam("id") Long id) {
return boxService.getBoxById(5L);
}
}
This is the bean:
@Stateless
public class BoxServiceImpl implements IBoxService {
@Override
public List<BoxDTO> getBoxesForDate(Date date,
DateType type) {
List<BoxDTO> boxes = new ArrayList<>(4);
return boxes;
}
@Override
public BoxDTO getBoxById(Long id) {
BoxDTO box = new BoxDTO();
return box;
}
}
Additionally I have the Application extending class which has no overriden implementation:
@ApplicationPath("/rest")
public class BoxesRestApplication extends Application {
}
My web.xml contains only a JSF servlet, and nothing besides that. I have the beans.xml files in each module. However, the EJB won't get injected. I have also tried with @Inject with the same result. The REST resource itself gets published and I can call the test method, but when calling the other two methods it fails with NullPointerException. I have already read tons of tutorials and solutions, however, none worked for me. Thank you your help.