<openjpa-2.2.1-r422266:1396819 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: Can only perform operation while a transaction is active.
针对同一个事务管理器,在开启事务之后又再开启一次,即如下代码,在上一个方法调用:
markMsg(String[] ids,String userid) 时,本方法内部又重新开启了一次事务。
/*** * 标记已读消息 * @author JianWu Zhang * <br>2015年3月30日 下午6:29:24 * @param request * @param response */ public void markReadedMsg(HttpServletRequest request, HttpServletResponse response){ AsyncContext act =ReqTool.ajax(request); MessageInfo info =new MessageInfo(MessageInfo.FAILE, "系统繁忙,请重试!"); AjaxEntity ajaxEn =new AjaxEntity(AjaxType.JSON,info); try { String id =Def2Val.strNotNUll(request.getParameter("ids")); String []ids =id.split(","); SysFactory.getSysManager().beginTransaction(true); boolean result =markMsg(ids,UserTool.User(request, response,false).getId()); SysFactory.getSysManager().commitTransaction(); if(result==true){ info.setDoResult(MessageInfo.SUCCESS); info.setMessage("标记成功!"); }else{ info.setDoResult(MessageInfo.FAILE); info.setMessage("标记失败!系统繁忙,请稍后重试"); } } catch (Exception e) { log.error("个人中心模块---标记已阅读出错!",e); }finally{ ajaxEn.setDate(info); new Thread(new AjaxRunnable(act,ajaxEn)).start(); } }
/** * 标记已阅读的消息 * @author JianWu Zhang * <br>2015年3月31日 上午11:30:00 * @param ids * @param userid * @return */ public boolean markMsg(String[] ids,String userid){ AccountMessageManager msgManager =SysFactory.getImplManager(AccountMessageManager.class); try { SysFactory.getSysManager().beginTransaction(true); boolean result= msgManager.markMsg(ids, DicUtil.READED, userid); SysFactory.getSysManager().commitTransaction(); return result; } catch (Exception e) { log.error("标记已阅读的消息出错!", e); return false; } }