I am using EJB 3.1 and jersey for a restapi. I would like to have a SuperResource
as below, which is then inherited by the actual rest resources as below. The way I have it now, my @EJB
object is null. Does anyone know how to fix this?
@Stateless
public class SuperResource {
@EJB
protected GenericDao<DomainObject> dao;
. . .
}
public class MyResource extends SuperResource{
public String doGet(){
return dao.get(...);
}
}
I have tried the whole truth table between @Stateless
and @Local
, and SuperResource
and MyResource
. None of the permutations seems to work.
I don't know if that's important, my server is Glassfish 3.1.2
EDIT TO ADD DETAILS:
I didn't think so , but it seems that more detail may be necessary here:
Structure of my application:
@Local
public interface GenericDao<T extends DomainObject> {…}
public interface LoginDao extends GenericDao<Login>{...}
@Stateless
public class GenericDaoImpl<T extends DomainObject> implements GenericDao<T> {…}
@Stateless
public class LoginDaoImpl extends GenericDaoImpl<Login> implements LoginDao {…}
@Entity
public class Login implements java.io.Serializable, DomainObject {…}
What works:
@Stateless
@Path("mypath")
public class MyResource{
@EJB
private LoginDao dao;
public String doGet(){
return dao.get(...);
}
}