2012-09-04 100 views
0

當按鈕單擊時,我需要在我的後臺運行的東西,所以我有一個異步Servlet。從我的託管bean中,如果我重定向,它的效果很好(這意味着它會在我的課程中正確執行我的run()方法,即extends Runnable)。像這樣從託管bean調度請求到異步Servlet生成異常

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

找到解決的:我是指你這篇文章: http://stackoverflow.com/questions/7855712/how-to-avoid-request-set-async-supported-true -to-使能異步-servlet的3-0-PROCES?RQ = 1 –

回答