【发布时间】:2015-01-19 07:46:53
【问题描述】:
我有 glassfish v4 和 2 个耳朵:
- Service.ear 包含 EJB。
- WebApplications.ear 包含 Web 应用程序。
我尝试使用:
@EJB(mappedName="java:global/Service/allServices/ServiceEJBs!Service1Remote")
Service1Remote service1Remot;
但我得到了错误:
原因:com.sun.faces.spi.InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: 尝试注入远程 ejb-ref name=java:global/Service/allServices/ 的异常ServiceEJBs!Service1Remote,Remote 3.x 接口 =Service1Remote,ejb-link=null,lookup=,mappedName=global/Service/allServices/ServiceEJBs!Service1Remote,jndi-name=,refType=Session 到类 com.manage.application.WebApplication : 空
但是当我使用 :
Service1Remote remote= (Service1Remote) new InitialContext().lookup("java:global/Service/allServices/ServiceEJBs!Service1Remote");
效果很好。
EJB:
@Remote
public interface Service1Remote{
public long getCount(int itemId);
}
@Stateless(name = "ServiceEJBs" , mappedName ="ServiceEJBs")
public Service1Bean implements Service1Remote{
public long getCount(int itemId){
...............
return 100000999;
}
}
【问题讨论】:
标签: java jakarta-ee ejb-3.0