java - 将 IBM StartupBean EJB1.1 迁移到 @Startup EJB3.1
问题描述
我们正在迁移以前使用 IBM 接口的 1.1 StartUp bean:
<session id="StartUp">
<ejb-name>StartUp</ejb-name>
<home>com.ibm.websphere.startupservice.AppStartUpHome</home>
<remote>com.ibm.websphere.startupservice.AppStartUp</remote>
<ejb-class>org.bean.StartUpBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
符合 EJB 3.1 标准。到目前为止,我们在没有使用 IBM 属性实现的情况下为 bean 编写代码:
@Startup
@Singleton
public class StartUpBean{
@PostConstruct
public void start() {
...
helper.runHelper(); // in new class
}
}
起初我们的部署顺序有问题,因为 StartupBean 是在模块之后立即启动的。我们在 application.xml 中使用不同的顺序解决了这个问题。然而,一个问题仍然存在。
在从这个 bean 的 start 方法调用的辅助方法中,我们有一些代码使用 JNDI 名称查找无状态 1.1 bean。该 bean 创建新的实体 bean (1.1),在新事务中调用方法 create(使用 xml 描述符中的 reguires_new)。然后它应该提交该事务以持久化该实体并调用在数据库中搜索该记录的 finder。看起来像:
void runHelper(){
...
oldRemote = Server.lookup(OldBean.JNDI, OldBean.class);
oldBean.prepareApp(); //prepareApp has requires new transaction attribute
findThatNewEntity(key); // FinderException (not in database)
}
在旧的无状态 bean 1.1
void prepareApp(){
entityHome = Server.lookup(JNDI_NAME, Data.class);
entityHome.create(key, value, value2);
}
我 100% 确定,在使用 IBM 接口的以前版本的 StartUp bean 中,实体被创建和存储。现在不是。我担心在应用程序启动时不支持事务。是这样吗?或者有什么方法可以强制使用事务或某种解决方法?谢谢你。
解决方案
推荐阅读
- tensorflow - 在 mAP 不稳定的情况下,我应该何时停止目标检测模型训练?
- javascript - 将 setInterval 设置为多次调用,但在本机反应中只调用一次
- fortran - 是否可以使用名称按数字顺序排列的向量进行循环?
- c++ - 为什么下面的代码不能编译(c++中的继承)
- python - Python 脚本突然从 PC 和 Dropbox 中消失了……?
- java - 为什么 describeConstable 是可选的?
- javascript - 如何使用 ReactJs 通过`props items` 实现`Search box`
- deep-learning - 如何解决 Docker Build 中的 bazel 构建错误?
- redirect - 使用 Microsoft Graph API 为控制台应用设置应用身份验证
- ios - UILabel,带有重划字符的 TextField