w13528476101
JQ棣
2017-06-14 08:25

atomikos jta事务异常

  • string
  • hibernate
  • 分布式
  • 事务

最近使用atomikos进行分布式事务开发,遇到以下问题:com.atomikos.datasource.ResourceException: XA resource 'ds': resume for XID '31302E3131362E3134302E3231352E746D313439373430373435373030313134323636:31302E3131362E3134302E3231352E746D353639303533' raised -9: the XA resource is currently involved in a local (non-XA) transaction。

这个异常是从一个hibernate查询中报出来的,不是每次查询都会报异常,偶尔会报,事务管理器使用的是JtaTransactionManager,基本代码如下:

 @Service("groundQuartzMonitorBiz")
@Transactional
public class QuartzMonitorBiz extends BaseBiz implements IQuartzMonitorBiz {

    private @Autowired IQuartzMonitorDao quartzMonitorDao;

    @Override
    @Transactional(readOnly = true)
    public Map<?,?> loadQuartzMonitor(String jobCode) {

        if (jobCode == null || "".equals(jobCode.trim())) {
            return null;
        }

        List<Map<?,?>> rets = quartzMonitorDao.loadQuartzMonitor(jobCode);
        if (null == rets || rets.isEmpty()) {
            return null;
        }
        return rets.iterator().next();
    }
}
 @Repository("groundQuartzMonitorDao")
public class QuartzMonitorDao extends CommonDao implements IQuartzMonitorDao {

    @Override
    @SuppressWarnings("unchecked")
    public List<Map<?, ?>> loadQuartzMonitor(String jobCode) {
        Query query = this.getCurrentSession().createSQLQuery(
                select id,job_code,startup_flg,cron_expression_flg,cron_expression,comments from ts_quartz_monitor t where t.job_code=:jobcode);
        query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
        query.setString("jobcode", jobCode);
        return query.list();
    }
}

哪位大神遇到过这种情况的请分享一下,不胜感激。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答