vendredi 31 juillet 2015

Maven: javax.enterprise.context.ContextNotActiveException while running tests with openejb

I've created some unit- and integration tests for mine Java-ee project with the help of OpenEjb and Junit with an embedded container. The tests are running fine in Eclipse, beans(CDI/EJB) are injected and working fine. But when I start the tests with maven and surefire, I get the following error:

WARNING: Handling the following exception
Throwable occurred: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:330)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:88)
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
at org.apache.webbeans.conversation.ConversationImpl$$OwbNormalScopeProxy0.isTransient(org/apache/webbeans/conversation/ConversationImpl.java)
at org.apache.wicket.cdi.ConversationPropagator.onUrlMapped(ConversationPropagator.java:322)
at org.apache.wicket.request.cycle.RequestCycleListenerCollection$9.notify(RequestCycleListenerCollection.java:208)

What could be wrong? It looks like a classpath issue or something, but explicit adding openwebbeans-spi and openwebbeans-impl didn't work.

I use the following lines in the testclass:

@ClassRule
public static final EJBContainerRule CONTAINER_RULE = new EJBContainerRule();

@Rule
public final InjectRule rule = new InjectRule(this, CONTAINER_RULE);

And I've the following openejb-junit.properties:

openejb.validation.output.level=VERBOSE
openejb.deployments.classpath.include=.*org.mine.*
openejb.descriptors.output=true
openejb.ejbcontainer.close=single-jvm
java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory

Thanks for any help.

Greetings, Huls.

Aucun commentaire:

Enregistrer un commentaire