Weld deployed on Arquillian fails to inject the bean if the inject point is annotated with @EJB and succeeds if it's annotated with @Inject, as the example below shows. Please note that I am in a situation where I can't change the definition of the X and Y class, so how can I tell Weld/Arquillian to take the definition of X? The following example (also attached as source code) fails as NullPointerException in the doSomething() method of class Y when x.doSomething() gets invoked, because x is not/doesn't get injected.
@Stateless
public class X {
public void doSomething() {
System.out.println("doing something...");
}
}
@Stateless
public class Y {
@EJB
private X x;
public void doSomething() {
x.doSomething();
}
}
@Test(groups = "main-group")
public class ArquillianTest extends Arquillian {
@Inject
private Y y;
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class).addClasses(X.class, Y.class).add(EmptyAsset.INSTANCE, "beans.xml");
}
public void someTest() {
y.doSomething();
}
}
P.S. Why does the configuration not fail, i.e. a missing dependency should be thrown by weld ?