从托管bean向Async Servlet的调度请求会生成异常

时间:2012-09-04 21:15:07

标签: java jsf servlets servlet-3.0 weblogic12c

当按下一个按钮时,我需要在后台运行东西,所以我有一个异步Servlet。从我的托管bean,如果我重定向,它工作得很好(意味着它在我的类run()正确执行我的extends Runnable方法。喜欢这个

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

但如果我切换到派遣,就像这样

externalContext.redirect("/ReportExecutionServlet");

当我尝试获取AsyncContext

时失败
AsyncContext aCtx = request.startAsync(request, response);

错误低于

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

请知道如何解决这个问题?

注意:这是如何执行我的异步servlet,以防万一:

    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));

1 个答案:

答案 0 :(得分:0)

JSF 2.x不支持异步功能,因此它无法正常工作。更多信息可以在FacesServlet Servlet 3.0 Async Support

找到