Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
When starting a batch via the batchee-cli runner (with batchee-cdi.jar in lib/ and openejb.scan.webapp.container=true) I get a ContextNotActiveException for RequestScoped beans.
public class EntityManagerProducer { @PersistenceUnit(unitName = "unitname") private EntityManagerFactory emf; @Produces @RequestScoped public EntityManager createEntityManager() { return emf.createEntityManager(); } } public class MyReader implements ItemReader { @Inject EntityManager em; }
results in:
Caused by: 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:335) at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:89) at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:71) at org.apache.webbeans.custom.persistence.EntityManager$$OwbNormalScopeProxy0.createNativeQuery(javax/persistence/EntityManager.java) at at.customer.testbatch.SomeStatistikReader.doRead(SomeStatistikReader.java:56) at at.customer.testbatch.SomeStatistikReader.doRead(SomeStatistikReader.java:20) at org.apache.batchee.extras.typed.TypedItemReader.readItem(TypedItemReader.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.batchee.container.proxy.BatchProxyInvocationHandler.invoke(BatchProxyInvocationHandler.java:55) at com.sun.proxy.$Proxy86.readItem(Unknown Source) at org.apache.batchee.container.impl.controller.chunk.ChunkStepController.readItem(ChunkStepController.java:284) ... 16 more