Sto iniettando un bean in un servlet Asynchronous e chiamando il metodo @Asynchronous
da Serrvlet. Nei log del server di jboss non sono in grado di vedere nessuna eccezione, ma quando avvii Java Mission Control, Flight Recorder posso vedere ContextNotActiveExcetion
ogni volta che Servlet effettua una chiamata al metodo @Asyncrhonous
.ContextNotActiveException durante la chiamata al metodo @Asynchronous del bean @Stateless
Servlet ::
@WebServlet(urlPatterns = { "/asyncservice" }, asyncSupported = true)
public class AsyncServiceServlet extends HttpServlet {
@Inject
private Service service;
protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
final AsyncContext asyncContext = request.startAsync(request, response);
asyncContext.start(new Runnable() {
@Override
public void run() {
try {
service.service(asyncContext);
} catch (ContextNotActiveException | IOException e) {
e.printStackTrace();
}
});
}
classe Servizio ::
@Stateless
public class Service {
@Asynchronous
public void service(final AsyncContext asyncContext) throws IOException {
HttpServletResponse res = (HttpServletResponse) asyncContext.getResponse();
res.setStatus(200);
asyncContext.complete();
}
}
l'analisi dello stack posso vedere nel registratore di volo ::
java.lang.Throwable.<init>() 4
java.lang.Exception.<init>() 4
java.lang.RuntimeException.<init>() 4
javax.enterprise.context.ContextException.<init>() 4
javax.enterprise.context.ContextNotActiveException.<init>() 4
org.jboss.weld.context.ContextNotActiveException.<init>(Enum,Object[]) 4
org.jboss.weld.manager.BeanManagerImpl.getContext(Class) 4
org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(InterceptorContext) 4
org.jboss.invocation.InterceptorContext.proceed() 4
org.jboss.invocation.InitialInterceptor.processInvocation(InterceptorContext) 4
org.jboss.invocation.InterceptorContext.proceed() 4
org.jboss.invocation.ChainedInterceptor.processInvocation(InterceptorContext) 4
org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(InterceptorContext) 4
org.jboss.invocation.InterceptorContext.proceed() 4
org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(InterceptorContext) 4
org.jboss.invocation.InterceptorContext.proceed() 4
org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(InterceptorContext,TransactionManager,EJBComponent) 4
org.jboss.as.ejb3.tx.CMTTxInterceptor.required(InterceptorContext,EJBComponent,int) 4
org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(InterceptorContext)
Vado attraverso molte post, ma il problema rimane lo stesso, ti prego di darmi una mano.
è che l'intero stacktrace? Inoltre, come costruisci il progetto (Maven, Ant)? Sei sicuro che manchi qualche dipendenza? :) –
Quale versione di JBoss AS? Impossibile riprodurre in WildFly 8.2. Funziona bene, quindi sembra proprio un bug nella versione di Weld, come usato nel tuo JBoss AS. Potrebbe anche essere utile eseguire l'aggiornamento a WildFly o almeno la versione di Weld utilizzata in WildFly 8.2. – BalusC
Sto usando jboss eap 6.1, questo non produrrà alcun bug/eccezione in nessuno dei log del server o dell'output della console, ma se avvierai il controllo della missione Java e avvierai il java flight recorder puoi vedere ContextNotActiveException nel codice >> Exception. –