当按下一个按钮时,我需要在后台运行东西,所以我有一个异步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));