I am trying to implement stateless EJB3 with remote and local interfaces, the problem is that the local call is called on another remote EJB with @EJB annotation, but it returns null or ClassCastException ( java.lang.ClassCastException: com.sun.proxy.$Proxy58 cannot be cast ).
To do a server search to get local stateless, I have to put 2 JNDI names for stateless, otherwise it will give me the remote.
@Stateless(mappedName=IRemoteInterface.JNDI_NAME, description="...") @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Interceptors({GenericInvocationHandler.class}) @Remote(IRemoteInterface.class) @Local(ILocalInterface.class) public class MystatelessBean extends AbstractBasicBean implements IRemoteInterface, ILocalInterface { ... } @Stateless(mappedName=IRouting.JNDI_NAME, description="gives access to other services") @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Interceptors({GenericInvocationHandler.class}) @Remote(IRouting.class) public class RoutingServiceBean extends AbstractBasicBean implements IRouting { @EJB public ILocalInterface iLocalInterface; }
Actually, when I use @EJB , I get NPE , and when I use @EJB(beanName=IRemoteInterface.JNDI_NAME) , I get a ClassCastException , which is the correct JNDI name of the remote interface.
I am looking for something like @LocalBinding and @RemoteBinding in JBoss.
Maybe something is missing for me?
source share