Hello,
I try to use TestNG but the @EJB is null, but it's not a detailed error :(( . I use arquillian but I doubt that this is the problem in this case, I've made other tests just like this whit different services but the EJ is not null, only 4 out 0f 10 services are null. :0
In the surfire reports it shows:
SubscriptionSaveTest(com.project.scr.prj.service.SubscriptionServiceTest) Time elapsed: 0.015 sec <<< FAILURE!
java.lang.NullPointerException
at com.project.scr.prj.service.SubscriptionServiceTest.SubscriptionSaveTest(SubscriptionServiceTest.java:98)
The test looks like
public class SubscriptionServiceTest {
private final String TEST_VALUE = "test";
private final Date TEST_DATE = new Date();
private final Long TEST_LONG = 3l;
@Deployment
public static WebArchive createTestArchive() {
return ShrinkWrap.create( WebArchive.class,"test.war").addPackages(true,"org.joda.time").addPackages(true, "javax.jcr").addClasses(com.mysql.jdbc.log.Log.class,com.project.scr.prj.model.Subscription.class).addPackage("org.slf4j").addPackage("org.slf4j.spi").addPackage("org.slf4j.helpers").addAsWebInfResource("test-persistence.xml", "classes/META-INF/persistence.xml").addAsWebInfResource("beans.xml", "META-INF/beans.xml");
}
@EJB(name ="subscriptionService")
private SubscriptionService subscriptionService;
@BeforeTest
@UsingScript("import.sql")
public void setUp()
{}
public Subscription FillSubscription(){
System.out.println("TEST"+subscriptionService); // in the console shows null
}
Sorry for my bad english :)
Best Regards