I have an @EJB
injected bean TransactionCompleteJob
. This bean has an @Asynchronous
method on it asyncCompleteTransaction(Integer transactionId)
.
When I try to make use of other injected beans and entities that are either session scoped or conversation scoped within this method I end up getting an error:
WELD-001303: No active contexts for scope type javax.enterprise.context.ConversationScoped
So I Injected weld's BoundConversationScope
, BoundSessionScope
, and BoundRequestScope
and activated them, generating an empty map for the request data, and an empty map for the session data, as specified by jboss weld documentation:
The problem is that when activating the request scope I get another error message:
WELD-001304: More than one context active for scope type javax.enterprise.context.RequestScoped
I've tried not activating the request scope, but I seem to end up with a resource leak of anything which was on the actual request scope, specifically I have a request scoped JPA EntityManager
. In particular once the process finishes I see another message:
WELD-000019: Error destroying an instance org.hibernate.jpa.internal.EntityManagerImpl@5df070be of Producer Method [EntityManager] with qualifiers [@RequestScopey @Any] declared as [[BackedAnnotatedMethod] @Produces @RequestScoped @RequestScopey public packagename.entitymanager.EntityManagerProducer.createRequestScopedEntityManager()]
How can I start a Request Scope Context when I have one already active? Or start a Session Scope Context and Conversation Scope Context which tie in to the existing Request Scope Context? Alternatively, are there any better ways to get around this issue?
EDIT:
Is there any way to get hold of the RequestScope
from weld so I can deactivate it, before starting my own? Or a way to Asynchronously start my TransactionCompleteJob
asynchronously, without injecting it and calling the @Asynchronous
method?
Aucun commentaire:
Enregistrer un commentaire