[英]global transaction websphere 8.5.5.11 ejb
我有一個界面:
public interface LogBookService extends EntityService<LogBookEntity, Long> {
void writelogNewTransaction(LogBookEntity log);
}
及其實施:
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class LogBookServiceImpl implements LogBookService {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void writelogNewTransaction(logBookEntity logbook) {
final List<String> params = new ArrayList<String>();
new getRepository().merge(entity);
}
}
和第三項服務:
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class GalaxyServiceImpl implements GalaxyService {
@Resource
private SessionContext sessionContext ;
public void test() {
for (LogBookEntity log : LogBookEntities) {
sessionContext.getBusinessObject(LogBookService.class).writelogNewTransaction(log);
}
}
}
例如,當我通過 Web 服務調用 GalaxyServiceImpl 時,出現此錯誤:
SystemErr R java.lang.IllegalStateException: Requested business interface not found : LogBookService
SystemErr R at com.ibm.ejs.container.SessionBeanO.getBusinessObject(SessionBeanO.java:677)
你能告訴我為什么嗎?
SessionContexts 特定於每個 bean 實例。 由於您在 GalaxyServiceImpl bean 中執行依賴項注入,因此您正在獲取該 bean 的 SessionContext,而不是 LogBookServiceImpl bean。 GalaxyServiceImpl 沒有實現 LogBookService 所以這就是為什么它抱怨你找不到它,因為它是業務接口。
相反,您可以使用 @EJB 注入 LogBookServiceImpl bean 或執行 JNDI 查找以找到該 bean。 您可以使用您注入的 SessionContext 作為 JNDI 查找的上下文或獲取 InitialContext。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.