代码改变世界

(转载)JBoss 4.2.3下部署EJB 3.0碰到的local和remote问题

2011-05-04 11:49  会被淹死的鱼  阅读(305)  评论(0编辑  收藏  举报
1 import javax.ejb.Local;
2  import javax.ejb.Remote;
3  import javax.ejb.Stateless;
4
5 @Stateless
6 @Remote
7 @Local
8 public class UserManagerBean implements UserManager {
9
10 public void addUser(User user) {
11 System.out.println(user.getUsername() + "已经被成功保存!");
12 user.setId(13);
13 }
14
15 }

在jboss 4.2.3.GA部署后发现问题

Local and Remote Interfaces cannot have duplicate interface for bean

解决方法, 在@Local和@Remote必须明确写上接口的类型:

1 import javax.ejb.Local;
2 import javax.ejb.Remote;
3 import javax.ejb.Stateless;
4
5 @Stateless
6 @Remote(UserManager.class)
7 @Local(UserManager.class)
8 public class UserManagerBean implements UserManager {
9
10 public void addUser(User user) {
11 System.out.println(user.getUsername() + "已经被成功保存!");
12 user.setId(13);
13 }
14
15 }

原文地址: http://www.blogjava.net/Bobbyliao/archive/2008/10/01/232018.html