@Local注釋和@Remote注釋不能一起使用

來源:互聯網
上載者:User

EJB @Local注釋和@Remote注釋不能一起使用 :Remote和Local方式寫在同一個類上,在部署到jboss4.0可以,jboss5.0報錯

在4.X版本上就可以同時寫在一個類上,代碼如下:

public interface UserManager {public void save(UserTest user);}@Stateless@Remote@Localpublic 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);}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.