在同一JBOSS实例(同一JVM)上的2个不同应用程序中访问本地接口(EJB3)

时间:2015-08-06 19:48:12

标签: jboss7.x jndi ejb-3.1

我可以从同一JBOSS实例中的其他应用程序访问本地接口吗? 例: 在我的共享库中:

@Local
class EmployeeLocal {
    void doAction();}
@Remote 
class EmployeeRemote{
    void doAction();
}

EAR Application:
@Stateless
class EmployeeService implements EmployeRemote,EmployeeLocal {
    @Override
    public doAction() { System.out.println(“Do something!”)};
    }
}


WAR Application:
public AccessEJB {
    @EJB
    IEmployeeLocal employeLocal; 

//注入也不起作用,抛出异常说不是EJB“引起了//by:org.jboss.as.server.deployment.DeploymentUnitProcessingException:// JBAS014544:找不到带有'IEmployeeLocal'类型接口的EJB

    public void doSomethingWithEJB() {
            IEmployeeRemote iEmployee =
                (IEmployeeRemote ) context.lookup("ejb:" + appName + "/" + moduleName + "/EmployeeService!EmployeRemote");
                iEmployee.doAction(); //THIS WORKS
                            IEmployeeLocal iEmployeeLocal =
                (IEmployeeLocal) context.lookup("ejb:" + appName + "/" + moduleName + "/EmployeeService!EmployeLocal");
                iEmployee.doAction(); //THIS DOESN'T WORK   
}

}

如果可以,请提供一个示例(需要jboss配置)。我已经尝试过依赖注入,各种jndi查找

0 个答案:

没有答案