我可以从同一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查找