I use Arquillian to test an stateless session bean that has an explicit local and remote interface. But in the test Arquillian does not \"inject\" anything in a field that has t
You could use one of the following:
Add a beans.xml file to the deployment:
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(
TestServiceLocal.class,
TestServiceRemote.class,
TestServiceImpl.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
This enables the CDITestEnricher of Arquillian, which is far more capable than the EJBTestEnricher. It can handle @Inject annotations (obviously), but also @Resource and @EJB annotations as well (see the section on Resources injection in the CDI spec). The container then treats both the @EJB annotated fields in your test class instance as injection points and injects the dependencies.
Specify the mappedName property for the @EJB annotation for the field with the portable JNDI name of the deployed bean. In your case, it will look something like:
@EJB(mappedName="java:global/test/TestServiceImpl!com.acme.TestServiceLocal")
private TestServiceLocal testServiceLocal;
You'll need to ensure that the portable JNDI name is the same as that the one generated for your deployment. I've merely specified the one that was generated for my "com.acme.TestServiceLocal" interface.