Ich bin eine @Stateless
Bean in einem asynchronen Servlet injizieren und Aufruf @Asynchronous
-Methode von der Serrvlet. In den Serverprotokollen des Jboss kann ich keine Ausnahme sehen, aber beim Starten des Java Mission Controls, Flight Recorder, kann ich ContextNotActiveExcetion
sehen, wann immer Servlet die Methode @Asyncrhonous
aufruft.ContextNotActiveException beim Aufruf von @Asynchronous-Methode von @Stateless Bean
Servlets ::
@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();
}
});
}
Service-Klasse ::
@Stateless
public class Service {
@Asynchronous
public void service(final AsyncContext asyncContext) throws IOException {
HttpServletResponse res = (HttpServletResponse) asyncContext.getResponse();
res.setStatus(200);
asyncContext.complete();
}
}
die Stack-Trace i im Flug Recorder sehen können ::
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)
Ich habe durch viele gegangen Beiträge, aber immer noch das Problem gleich bleiben, bitte helfen Sie mir aus.
Ist das die ganze Stacktrace? Wie baut man das Projekt (Maven, Ant)? Sind Sie sicher, dass keine Abhängigkeit fehlt? :) –
Welche JBoss AS Version? Kann nicht in WildFly 8.2 reproduziert werden. Funktioniert gut, sieht also nur wie ein Fehler in der Weld-Version aus, wie er in Ihrem JBoss AS verwendet wird. Es könnte sich auch lohnen, auf WildFly oder zumindest die Weld-Version zu aktualisieren, wie sie in WildFly 8.2 verwendet wird. – BalusC
Ich benutze jboss eap 6.1, dies wird keinen Fehler/Ausnahme in einem der Server-Logs oder Konsolen-Ausgabe erzeugen, aber wenn Sie Java Mission Control starten und Java-Flugschreiber starten, können Sie ContextNotActiveException in Code >> Exception sehen. –