Dispatch request to an Async Servlet from managed bean generate exception
Posted
by
Thang Pham
on Stack Overflow
See other posts from Stack Overflow
or by Thang Pham
Published on 2012-09-04T21:15:07Z
Indexed on
2012/09/04
21:38 UTC
Read the original article
Hit count: 358
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));
© Stack Overflow or respective owner