0

Im trying to migrate a stateful session bean from EJB 2.1 to EJB 3.0, the home interface of the bean which extends EJBHome has a create method with two args and the corresponding bean has a matching args ejbcreate method and one more no arg ejbcreate method. My question is- 1. do I need to create two constructors one no arg and one arg to migrate this stateful session bean? 2. The ejbcreate method code is throwing "CreateException" and a run time exception, as of now ejbcreate defines throws "CreateException", do i need to define thorws CreateException" on the constructor or can I skip the create exception throwing part in the code of the constructor.

Other alternative I see posted in one blog is creating a method and annotating with @init, though not sure if this is the way as they were talking about EJB2 client view for a EJB3 bean.

4

1 回答 1

0

不幸的是,在使用 EJB 3 创建有状态会话 bean 时无法指定参数,因此您需要添加一个 initialize(arg1, arg2) 方法并在通过 JNDI 获取实例后调用它。

在 EJB 3 中只能使用无参数构造函数。

@Init的,相当于ejbCreate在使用 EJB 3 样式 bean 定义时使用注释定义 EJB 2 客户端视图。

于 2014-04-16T05:54:51.737 回答