现在的位置: 首页 > 综合 > 正文

EJB3.0异常总结—javax.ejb.EJBException: Local and Remote Interfaces cannot have duplicate interface for

2019年09月16日 ⁄ 综合 ⁄ 共 776字 ⁄ 字号 评论关闭

javax.ejb.EJBException: Local and Remote Interfaces cannot have duplicate interface for bean UserManagerBean
at org.jboss.ejb3.SessionContainer.checkForDuplicateLocalAndRemoteInterfaces(SessionContainer.java:134)
at org.jboss.ejb3.SessionContainer.instantiated(SessionContainer.java:119)
at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:492)
at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:442)

UserManagerBean中的@Local,@Remote必须明确写上接口的类型,才可以。修改代码如下:

package cn.study.ejb;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless
@Remote(UserManager.class)
@Local(UserManager.class)
public class UserManagerBean
implements UserManager {

 public
void addUser(User user) {
        System.out.println(user.getUsername() + "已经被成功保存!");
        user.setId(13);

抱歉!评论已关闭.