【发布时间】:2015-09-26 16:04:30
【问题描述】:
我已将一个 Thread 类注释如下:
@Transactional(propagation = Propagation.REQUIRED)
@Component
@Scope("prototype")
public class ThreadRetrieveStockInfoEuronext implements Runnable {
...
}
线程被连接到一个控制器类中,并通过 Global.poolMultiple.execute(threadRetrieveStockInfoEuronext); 调用
public class RetrievelController {
@Autowired
private ThreadRetrieveStockInfoEuronext threadRetrieveStockInfoEuronext;
@RequestMapping(value = "/.retrieveStockInfo.htm", method = RequestMethod.POST)
public ModelAndView submitRetrieveStockInfo(@ModelAttribute("retrieveStockInfoCommand") RetrieveStockInfoCommand command, BindingResult result, HttpServletRequest request) throws Exception {
Global.poolMultiple.execute(threadRetrieveStockInfoEuronext);
return new ModelAndView(".retrieveStockInfo", "retrieveStockInfoCommand", command);
}
全局类:
@SuppressWarnings("unchecked")
@Component
public class Global {
// create ExecutorService to manage threads
public static ExecutorService poolMultiple = Executors.newFixedThreadPool(10);
public static ExecutorService poolSingle = Executors.newFixedThreadPool(1);
...
}
运行应用时,出现如下异常:
java.lang.IllegalArgumentException:无法设置 com.chartinvest.admin.thread.ThreadRetrieveStockInfoEuronext 字段
com.chartinvest.controller.RetrieveController.threadRetrieveStockInfoEuronext 到 com.sun.proxy.$Proxy52
【问题讨论】:
标签: java spring hibernate jpa transactional