I have glassfish v4 and 2 ears:
- Service.ear contains EJBs.
- WebApplications.ear contains Web Applications.
I try to use the:
@EJB(mappedName="java:global/Service/allServices/ServiceEJBs!Service1Remote")
Service1Remote service1Remot;
But I got error:
Caused by: com.sun.faces.spi.InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=java:global/Service/allServices/ServiceEJBs!Service1Remote,Remote 3.x interface =Service1Remote,ejb-link=null,lookup=,mappedName=global/Service/allServices/ServiceEJBs!Service1Remote,jndi-name=,refType=Session into class com.manage.application.WebApplication: null
But when I user the :
Service1Remote remote= (Service1Remote) new InitialContext().lookup("java:global/Service/allServices/ServiceEJBs!Service1Remote");
it works fine.
The 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;
}
}