【发布时间】:2013-02-23 11:29:03
【问题描述】:
现在我使用 Jersey 在 Websphere 8.5 上创建 RESTful Web 服务。
我还希望 RESTful Web 服务具有 EJB 3.1 的能力。
我的restful web服务代码如下:
@Stateless
@Path("/tagServiceRS/{tagid}")
@Interceptors(TestTagServiceInterceptor.class)
public class TagServiceRS implements Serializable{
private static final long serialVersionUID = 5L;
private static final Logger log = LoggerFactory.getLogger(TagServiceRS.class);
@EJB
private TagTestService tagTestService;
@PersistenceContext(unitName = "tag-ejb")
private EntityManager entityManager;
@GET
@Produces("text/plain")
public String findTagById(@PathParam("tagid") String tagid) {
return "TAG";
}
/**
* @return the tagTestService
*/
public TagTestService getTagTestService() {
return tagTestService;
}
/**
* @param tagTestService the tagTestService to set
*/
public void setTagTestService(TagTestService tagTestService) {
this.tagTestService = tagTestService;
}
当我在 Websphere 8.5 上部署战争时。 TagServiceRS 已成功部署为一个 RESTful Web 服务。我对其进行了测试。没关系。
但是 TagServiceRS 失败部署为 EJB 会话 bean。
TagServiceRS 的 entityManager 和 tagTestService 字段都是 null。
我看到日志,没有错误或警告日志。
下面是我的 TagTestServiceBean 代码。
@Stateless
public class TagTestServiceBean implements TagTestService, Serializable {
private static final long serialVersionUID = 5L;
private static final Logger log = LoggerFactory.getLogger(TagTestServiceBean.class);
@Override
public Tag testFindTagById(Long id) {
log.info("testFindTagById ++++++++++++++++++++++++++++++++++++++++ invoked for id: {}", id);
return new Tag();
}
}
@Remote
public interface TagTestService extends Serializable {
/**
* @param id
* the ID from database
* @return a tag, may null
*/
Tag testFindTagById(Long id);
}
如果有答案。非常感谢。
【问题讨论】:
-
也许你可以试试这里提到的其他方法:stackoverflow.com/questions/3027834/…
标签: ejb jersey websphere jax-rs websphere-8