iteye_6989
2008-06-17 00:36
浏览 249
已采纳

spring + hibernate +jta 事务不能回滚问题

由于在项目中 用到分布式事务 引用 http://momoko8443.iteye.com/blog/190994 的帖子 按照上面的配置事务不能回滚 ,对于单个数据库也是一样 问题困扰了我三天了 每天晚上查资料查到晚上3点,求各位帮帮我,先谢了

代码及其配置 如下
配置文件
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://www.springframework.org/schema/beans"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">


db_idcbase
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

URL=jdbc:mysql://127.0.0.1:3306/db_idcbase?useUnicode=true&characterEncoding=gb2312;user=root;password=admin

true
3
SELECT 1

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">





org.hibernate.dialect.MySQLDialect
true





com/yiwei/hibernate/bean/TblReportHosts.hbm.xml


com/yiwei/hibernate/bean/TblRuleUrls.hbm.xml


com/yiwei/hibernate/bean/TblRuleIps.hbm.xml


com/yiwei/hibernate/bean/TblRuleTcps.hbm.xml


com/yiwei/hibernate/bean/TblRuleUdps.hbm.xml


com/yiwei/hibernate/bean/TblReportUrls.hbm.xml


com/yiwei/hibernate/bean/TblReportKeys.hbm.xml


com/yiwei/hibernate/bean/TblReportTcps.hbm.xml


com/yiwei/hibernate/bean/TblReportUdps.hbm.xml


com/yiwei/hibernate/bean/TblRuleKeys.hbm.xml


com/yiwei/hibernate/bean/TblReportProbes.hbm.xml


com/yiwei/hibernate/bean/TblReportVhosts.hbm.xml


com/yiwei/hibernate/bean/TblRuleConfs.hbm.xml


com/yiwei/hibernate/bean/TblRuleType.hbm.xml



isp
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

URL=jdbc:mysql://127.0.0.1:3306/isp?useUnicode=true&characterEncoding=gb2312;user=root;password=admin

true
3

SELECT 1

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">





org.hibernate.dialect.MySQLDialect
true





com/yiwei/hibernate/bean/Carrier.hbm.xml


com/yiwei/hibernate/bean/UbietyDrawer.hbm.xml

com/yiwei/hibernate/bean/UbietyRoom.hbm.xml
com/yiwei/hibernate/bean/User.hbm.xml
com/yiwei/hibernate/bean/Host.hbm.xml
com/yiwei/hibernate/bean/Proxyer.hbm.xml
com/yiwei/hibernate/bean/Region.hbm.xml
com/yiwei/hibernate/bean/Role.hbm.xml

com/yiwei/hibernate/bean/SysPrincipal.hbm.xml


com/yiwei/hibernate/bean/SysRolePrincipal.hbm.xml


com/yiwei/hibernate/bean/SysUserRole.hbm.xml

com/yiwei/hibernate/bean/Log.hbm.xml
com/yiwei/hibernate/bean/Vhost.hbm.xml
com/yiwei/hibernate/bean/TblProxyerService.hbm.xml


true


300








class="com.yiwei.hibernate.bean.UbietyRoomDAO">




class="com.yiwei.business.service.UbietyRoomServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.UbietyDrawerDAO">




class="com.yiwei.business.service.UbietyDrawerServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED








class="com.yiwei.business.service.CarrierServiceImp">



class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED








class="com.yiwei.business.service.HostServiceImp">















class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED








class="com.yiwei.business.service.UserServiceImp">










class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblReportHostsDAO">




class="com.yiwei.business.service.ReportHostsServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED








class="com.yiwei.business.service.ProxyerServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED







class="com.yiwei.hibernate.bean.TblRuleUrlsDAO">




class="com.yiwei.business.service.RuleUrlsServiceImp">




















PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



<!--
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">




TblRuleIpsDAO -->
class="com.yiwei.hibernate.bean.TblRuleIpsDAO">




class="com.yiwei.business.service.RuleIpsServiceImp">










class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblRuleTcpsDAO">




class="com.yiwei.business.service.RuleTcpsServiceImp">










class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblRuleUdpsDAO">




class="com.yiwei.business.service.RuleUdpsServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblReportUrlsDAO">




class="com.yiwei.business.service.ReportUrlsServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblReportKeysDAO">




class="com.yiwei.business.service.ReportKeysServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED








class="com.yiwei.business.service.RoleServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblReportTcpsDAO">




class="com.yiwei.business.service.ReportTcpsServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblReportUdpsDAO">




class="com.yiwei.business.service.ReportUdpsServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.SysPrincipalDAO">



class="com.yiwei.business.service.SysPrincipalServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblRuleKeysDAO">




class="com.yiwei.business.service.RuleKeysServiceImp">










class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblReportProbesDAO">




class="com.yiwei.business.service.ReportProbesServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.SysRolePrincipalDAO">



class="com.yiwei.business.service.SysRolePrincipalServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.SysUserRoleDAO">



class="com.yiwei.hibernate.bean.TblReportVhostsDAO">




class="com.yiwei.business.service.ReportVHostServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblRuleConfsDAO">




class="com.yiwei.business.service.RuleConfsServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED








class="com.yiwei.business.service.LogServiceImp">



class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.TblRuleTypeDAO">




class="com.yiwei.business.service.RuleTypeServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



class="com.yiwei.hibernate.bean.HqlDAO">




class="com.yiwei.business.service.HqlServiceImp">




class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED













class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">






PROPAGATION_REQUIRED,readOnly,-Exception


PROPAGATION_REQUIRED,readOnly,-Exception

PROPAGATION_REQUIREDPROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED



<!--



-->

/** dao
public class TblRuleUrlsDAO extends HibernateDaoSupport implements IRuleUrlsDAO
public void save(TblRuleUrls transientInstance) {
log.debug("saving TblRuleUrls instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (DataAccessException re) {
log.error("save failed", re);
throw re;
}
}

/** dao
class LogDAO extends HibernateDaoSupport implements ILogDAO{
public void save(Log transientInstance) {
log.debug("saving Log instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (DataAccessException re) {
log.error("save failed", re);
throw re;
}
}

/** service
public class RuleUrlsServiceImp implements IRuleUrlsService {

private IRuleUrlsDAO ruleUrlsDAO;

private IRuleConfsDAO ruleConfsDAO;

private ILogDAO logDAO;
public IRuleUrlsDAO getRuleUrlsDAO() {
return ruleUrlsDAO;
}

public void setRuleUrlsDAO(IRuleUrlsDAO ruleUrlsDAO) {
this.ruleUrlsDAO = ruleUrlsDAO;
}

public void delete(TblRuleUrls persistentInstance) {
// TODO Auto-generated method stub

this.ruleUrlsDAO.delete(persistentInstance);

}

public TblRuleUrls findById(Integer id) {
// TODO Auto-generated method stub
return this.ruleUrlsDAO.findById(id);
}

public void insertUser(TblRuleUrls transientInstance,User u) {
// TODO Auto-generated method stub
try{
this.ruleUrlsDAO.save(transientInstance);
Log log = new Log();
log.setCarrierId(transientInstance.getIspID());
log.setDtime(transientInstance.getDtime());
log.setProxyerId(transientInstance.getProxyId());
String ip = transientInstance.getAssignIp().split(" ")[0];
log.setIp(ip);
log.setMessage("用户  部署了url规则 "+transientInstance.getHurl());
log.setUser(u);
log.setDtime("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
//ILogService logService = (ILogService)AppContext.getInstance().getAppContext().getBean("logService");
logDAO.save(log);
}
catch(DataAccessException e){
System.err.println("service 抛出异常");
throw e;
}

}

action

*/
public ActionForward ruleUrlsAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
RuleUrlsForm ruleUrlsForm = (RuleUrlsForm) form;// TODO Auto-generated
// method stub
try{
User u = (User) request.getSession().getAttribute("u");
TblRuleUrls url = new TblRuleUrls();
PropertyUtils.copyProperties(url, ruleUrlsForm);
url.setAction(ruleUrlsForm.getAct());
url.setAssignIp(request.getRemoteAddr() + " " + u.getRealName());
url.setDtime(Conversion.getDate(new Date()));
String hurl = ruleUrlsForm.getHurl();
if (ruleUrlsForm.getAct().equals("redi")||ruleUrlsForm.getAct().equals("rredi")) {
hurl = hurl + " " + ruleUrlsForm.getThurl();
}
url.setHurl(hurl);
url.setUserID(u.getId());
url.setIspID(u.getCarrierId());
url.setProxyId(u.getProxyerId());
this.getRuleUrlsService().insertUser(url,u);
}catch(DataAccessException e)
{
System.err.println("action 执行中发生异常");

}
ActionForward f = new ActionForward("ruleUrls.do?action=ruleUrlsList",
true);
return f;
}

jta 配置文件如下 c
om.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory

com.atomikos.icatch.enable_logging = false

com.atomikos.icatch.automatic_resource_registration = true

再次谢过

查了资料后 现将每个都加上了 PROPAGATION_REQUIRED,-ExceptionPROPAGATION_REQUIRED,-Exception
增加异常 但是还是不行
[b]问题补充:[/b]
现在将mysql 换成了6.0 还是不行 单数据库事务也不起作用 期待高手
[b]问题补充:[/b]
请问下3楼 会不会是table的engine是MyISAM类型的啊?
是什么意思
[b]问题补充:[/b]
三楼的 你好 我的数据类型是MyISAM类型

vhost | MyISAM | 10 | Dynamic | 9 | 348 |
3132 | 281474976710655 | 2048 | 0 | NULL | 20
8-06-17 10:48:04 | 2008-06-17 11:16:38 | NULL | utf8_general_ci | NUL
| | |MyISAM

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • llade163 2008-06-17 14:36
    已采纳

    会不会是table的engine是MyISAM类型的啊?

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • iteye_19907 2008-06-17 01:14

    帖子太长,懒得看,睡觉了

    评论
    解决 无用
    打赏 举报
  • lggegegmail 2008-06-17 09:56

    仔细看了, 配置没问题.

    是否你家的Mysql不支持事务? [应该不会有这个问题]
    show table status from db_idcbase;

    关注中...

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题