EJB @Local注释和@Remote注释不能一起使用 :Remote和Local方式写在同一个类上,在部署到jboss4.0可以,jboss5.0报错
在4.X版本上就可以同时写在一个类上,代码如下:
public interface UserManager { public void save(UserTest user); } @Stateless @Remote @Local public class UserManagerBean implements UserManager, UserManagerLocal{ public void save(UserTest user) { System.out.println("User[username=" + user.getUsername() +"]已保存" ); user.setId(1); } }
5.0版本就不行,报错如下:
Caused by: java.io.InvalidClassException: org.jboss.ejb3.remoting.IsLocalInterceptor; local class incompatible:stream classdesc serialVersionUID = -3758782076801249473, local classserialVersionUID = 337700910587744646
DEPLOYMENTS IN ERROR:
Deployment"vfsfile:/E:/javaprogram/jboss-5.0.1.GA/server/default/deploy/ejb_03.jar/"is in error due to the following reason(s):javax.ejb.EJBException: Cannot designateboth javax.ejb.Local and javax.ejb.Remote annotations without 'value' attributeon UserManagerBean. [EJBTHREE-1025]
问题具体描述及解决:
http://topic.csdn.net/u/20090202/20/b888766f-5fd4-40a3-b886-bd1e04c6f758.html
jboss4.x版本可以一个接口定义为remote和local两种方式,jboss5.0版本的则需要定义两个接口,并明确写明(当然具体实现的方式有多种):代码如下:
public interface UserManager { public void save(UserTest user); } public interface UserManagerLocal { public void save(UserTest user); } @Stateless @Remote({UserManager.class}) @Local({UserManagerLocal.class}) public class UserManagerBean implements UserManager, UserManagerLocal{ public void save(UserTest user) { System.out.println("User[username=" + user.getUsername() +"]已保存" ); user.setId(1); } }