如何将作为方法参数接收的HttpServletRequest对象使用在同一方法中声明的新线程中

时间:2019-01-12 00:36:41

标签: java rest servlets jax-rs weblogic

我有以下代码:

public void doSomething(HttpServletRequest requestContext){
     new RequestProcessor(requestContext).process();
}

private class RequestProcessor implements Runnable {


public RequestProcessor(HttpServletRequest request) 
  {
    this.request = request;
  }

  private void process() {
    new Thread(this).start();
  }

  public void run() {
    System.out.println(request.toString())  //ignore the logic here, is only a example...
  }
}

但是当实例化请求处理器时,出现以下异常:

java.lang.IllegalStateException: No thread local value in scope for proxy of class com.sun.proxy.$Proxy

我需要将完整的HttpservletRequest发送到线程,是否存在执行此操作的方法?

0 个答案:

没有答案