NutzCN Logo
问答 线程池启动事务报空指针异常
发布于 2923天前 作者 qq_88dd2c69 2421 次浏览 复制 上一个帖子 下一个帖子
标签:
fixedThreadPool.execute(new Runnable() {
			public void run() {
				Trans.exec(new Atom() {
					public void run() {
						String tableName = "POS_T_SAVEFLOW s "
								+ "LEFT JOIN POS_T_VIP_INFO  i ON s.CARD_ID=i.CARD_ID ";
								
						Cnd cnd = Cnd.where(null).andNot("s.flow_id", "in",
								"(select flow_id from SMS_PAY)");
						String fields = "s.FLOW_ID,s.reduce_amt,i.VIP_NAME,i.VIP_TEL,s.oper_date";
						DaoImpl dao = InitService.getDao();
						List<Record> list = dao.query(tableName, cnd, fields);

						dao.insert(
									"SMS_PAY",
									Chain.make("FLOW_ID",
											record.getString("FLOW_ID")));

							
						}
					}
				});

我是在线程池开启新线程并执行事务,异常信息如下:

Exception in thread "pool-24-thread-3" Exception in thread "pool-24-thread-1" 	at org.nutz.trans.Trans.exec(Trans.java:123)
	at com.jinyatu.init.MsmSendOnMinutes$2.run(MsmSendOnMinutes.java:125)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

MsmSendOnMinutes.java:125对应的就是Trans.execute(new Atom(){这里

9 回复

它是有时候报异常,有时候又正确,不知道问题出在哪里了

125行是什么

@wendal 125行对应的就是"Trans.exec(new Atom() {"

哪一个版本?

老项目,nutz-1.b.50,是不是该升级了?

我觉得你没把异常信息贴完整

Trans.exec 在1.b.52 的代码是 exec(Connection.TRANSACTION_READ_COMMITTED, atoms); 更高的版本上这一行是空行.

@wendal 我刚刚升级到1.r.55,OK了

添加回复
请先登陆
回到顶部