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