Frage

when a button click, I need to have stuff running in my background, so I have a async Servlet. From my managed bean, if I do redirect, it works great (meaning that it execute my run() method inside my class that extends Runnable correctly). Like this

String url = externalContext.getRequestContextPath() + "/ReportExecutionServlet";
externalContext.redirect(url);

But if I switch to dispatch, like this

externalContext.redirect("/ReportExecutionServlet");

it fail when I try to obtain the AsyncContext

AsyncContext aCtx = request.startAsync(request, response);

The error is below

Caused By: java.lang.IllegalStateException: The async-support is disabled on this request: weblogic.servlet.internal.ServletRequestImpl

Any idea how to fix this please?

NOTE: This is how to execute my async servlet, just in case:

    AsyncContext aCtx = request.startAsync(request, response);            
    //delegate long running process to an "async" thread
    aCtx.addListener(new AsyncListener() {

        @Override
        public void onComplete(AsyncEvent event) throws IOException {
            logger.log(Level.INFO, "ReportExecutionServlet handle async request - onComplete");
        }

        @Override
        public void onTimeout(AsyncEvent event) throws IOException {
            logger.log(Level.WARNING, "ReportExecutionServlet handle async request - onTimeout");
        }

        @Override
        public void onError(AsyncEvent event) throws IOException {
            logger.log(Level.SEVERE, "ReportExecutionServlet handle async request - onError");
        }

        @Override
        public void onStartAsync(AsyncEvent event) throws IOException {
            logger.log(Level.INFO, "ReportExecutionServlet handle async request - onStartAsync");
        }
    });
    // Start another service
    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);            
    executor.execute(new AsyncRequestReportProcessor(aCtx));
War es hilfreich?

Lösung

JSF 2.x does not support async feature, so that why it is not working. More information can be found here FacesServlet Servlet 3.0 Async Support

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top