[jboss-jira] [JBoss JIRA] (WFLY-8942) Request Scope is not active during Batchlet

James Perkins (JIRA) issues at jboss.org
Wed Jul 5 13:55:00 EDT 2017


    [ https://issues.jboss.org/browse/WFLY-8942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13431304#comment-13431304 ] 

James Perkins commented on WFLY-8942:
-------------------------------------

The problem seems to be the {{RequestScopeContext}} is destroyed before the injected bean is used. My guess is since the HTTP request is complete, the context is destroyed. We may need something similar to what is being done for EJB {{@RequestScope}}. Part of the EJB implementation seems to be in Weld Core and the other part in WildFly.

[~mkouba] We may need your thoughts here. I'll attach a WAR which will easily reproduce this issue. Currently batch creates the beans like [this|https://github.com/wildfly/wildfly/blob/master/batch/extension-jberet/src/main/java/org/wildfly/extension/batch/jberet/deployment/WildFlyArtifactFactory.java#L52]. This creation part would happen before a new batch thread is launched. This is why I think the bean has essentially fell out of scope because it lazily loads the injected {{@RquestScope}} bean in a new thread.

Is there an easy way to handle this?

> Request Scope is not active during Batchlet
> -------------------------------------------
>
>                 Key: WFLY-8942
>                 URL: https://issues.jboss.org/browse/WFLY-8942
>             Project: WildFly
>          Issue Type: Bug
>          Components: Batch, CDI / Weld
>    Affects Versions: 10.1.0.Final
>         Environment: Wildfly 10.1.0 Final
>            Reporter: Cody Lerum
>            Assignee: James Perkins
>
> When executing a Java EE 7 batchlet if an injection of an @RequestScoped bean is attempted.
> Example
> {noformat}
> 20:57:13,995 WARN  [org.jberet] (Batch Thread - 13) JBERET000001: Failed to run batchlet org.jberet.job.model.RefArtifact at b5b6a97: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
> 	at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:689)
> 	at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:90)
> 	at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:165)
> 	at org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
> 	at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:83)
> 	at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list