[
https://issues.jboss.org/browse/WFLY-7841?page=com.atlassian.jira.plugin....
]
Tibor Digana commented on WFLY-7841:
------------------------------------
Guys, the cdi concurrency without automatically activated context is really useless.
Automatically activating the context is the idea of the word "Managed" in the
executor interface; otherwise I could simply use J2SE utilities without making any
difference.
As a comparison with EJB 3.0 @Schedule the request scope works and it is the only scope of
the bean which makes sense; otherwise I could not imaging any other scope like session or
view which has obviously no notion about HTTP. As a comparison with EJB Timer, even if you
try to fetch {{SessionScoped}} EJB bean to the EJB Thread you may expect an exception. And
therefore request scope in managed thread means for me that the {{#submit() method}} forks
as short lifecycle as possible and I have guarantee that two calls of {{#submit() method}}
successfully isolates the jobs and no data is shared which is perfect isolation which in
J2SE would not be anyhow more simple without using {{ThreadLocal}} and therefore CDI is so
perfect and straightforward for me.
ManagedScheduledExecutorService could not find EntityManager produced
by CDI producer. No active context.
---------------------------------------------------------------------------------------------------------
Key: WFLY-7841
URL:
https://issues.jboss.org/browse/WFLY-7841
Project: WildFly
Issue Type: Bug
Components: CDI / Weld
Affects Versions: 10.0.0.Final, 10.1.0.Final
Reporter: Tibor Digana
Assignee: Stuart Douglas
The problem is that _EntityManager_ does not have managed delegate within a job executed
by _ManagedScheduledExecutorService#scheduleAtFixedRate()_.
The _EntityManager_ is produced by CDI producer and entire web application is able to
work with injected _EntityManager_ except for the jobs.
I tried to schedule executing the job in two ways and both finished with same issue (No
managed context in _EntityManager_) :
* _@ApplicationScoped_ job instance was passed to executor from caller.
* The job was changed to _RequestScoped_ and _ContextProxy#createContextualProxy()_
created the Job bean instance and then I called _scheduleAtFixedRate(job, 5, 60,
SECONDS)_
It looks to me that _javax.enterprise.concurrent_ has a different _BeanManager_ and
therefore has no notion about my CDI Producer of _EntityManager_. The producer is regular
producer of _EntityManager_ in JavaEE.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)