可以将无状态 session bean 注入(inject) jsf 托管 bean 中吗?
我有
@ManagedBean(name = "imageUpload")
@RequestScoped
public class ImageUploadBean extends FileUploadBean {
@EJB
GenericEntityService genericEntityService;
...
}
public interface GenericEntityService {
<T> T getById(int id, Class<T> entityClass);
void deleteById(int id, Class entityClass);
}
@Stateless
public class GenericEntityServiceImpl
extends EntityServiceBase implements GenericEntityService
{
...
}
genericEntityService 始终为 null,我不知道为什么
我使用 tomee-webprofile-1.5.2
任何帮助或示例链接将不胜感激
最佳答案
更新:这个答案很有用,因为默认情况下界面是@Local
AFAIR 这可能是因为您需要在界面上指定本地或远程注释,尝试一下:
@Local
public interface GenericEntityService {
<T> T getById(int id, Class<T> entityClass);
void deleteById(int id, Class entityClass);
}
关于java - 将无状态注入(inject) ManagedBean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20618656/