You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@batchee.apache.org by "Mark Struberg (JIRA)" <ji...@apache.org> on 2017/11/20 15:42:00 UTC

[jira] [Updated] (BATCHEE-124) RequestScoped ContextNotActiveException in CLI

     [ https://issues.apache.org/jira/browse/BATCHEE-124?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Struberg updated BATCHEE-124:
----------------------------------
    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.

{code}
public class EntityManagerProducer {
    @PersistenceUnit(unitName = "unitname") private EntityManagerFactory emf;

    @Produces @Request public EntityManager createEntityManager() {
        return emf.createEntityManager();
    }
}

public class MyReader implements ItemReader {
    @Inject EntityManager em;
}
{code}
results in:
{code}
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
{code}

  was:
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.

{code}
public class EntityManagerProducer {
    @PersistenceUnit(unitName = "unitname") private EntityManagerFactory emf;

    @Produces @Request public EntityManager createEntityManager() {
        return emf.createEntityManager();
    }
}

public class MyReader implements ItemReader {
    @Inject EntityManager em;
}
{code}
results in:
{code}
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.sozvers.pva.testbatch.KontoerstgutschriftStatistikReader.doRead(KontoerstgutschriftStatistikReader.java:56)
        at at.sozvers.pva.testbatch.KontoerstgutschriftStatistikReader.doRead(KontoerstgutschriftStatistikReader.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
{code}


> RequestScoped ContextNotActiveException in CLI
> ----------------------------------------------
>
>                 Key: BATCHEE-124
>                 URL: https://issues.apache.org/jira/browse/BATCHEE-124
>             Project: BatchEE
>          Issue Type: Bug
>          Components: batchee-cli
>            Reporter: Alexander Falb
>
> 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.
> {code}
> public class EntityManagerProducer {
>     @PersistenceUnit(unitName = "unitname") private EntityManagerFactory emf;
>     @Produces @Request public EntityManager createEntityManager() {
>         return emf.createEntityManager();
>     }
> }
> public class MyReader implements ItemReader {
>     @Inject EntityManager em;
> }
> {code}
> results in:
> {code}
> 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
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)