请问hibernate保存对象的错误!
我通过hibernate保存po,但出现了错误:org.hibernate.TransactionException: Could not register synchronization for container transaction
at org.hibernate.transaction.CMTTransaction.begin(CMTTransaction.java:45)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at com.ct.hibernate.HibernateSessionFactory.beginTransaction(HibernateSessionFactory.java:125)
at com.ct.dao.DaoManagement.saveOrUpdate(DaoManagement.java:60)
at com.ct.dao.CtrlTowerDao.saveOrUpdateObj(CtrlTowerDao.java:142)
at com.ct.biz.Thread.adapter.InnerMqReceiveADP.run(InnerMqReceiveADP.java:146)
at com.ct.biz.Thread.ThreadPool$PoolWorker.run(ThreadPool.java:169)
哪位碰到过这样的问题,或者有经验,提示我一二,我这里多谢了。 --------------------编程问答-------------------- 怎么没人回复呀? --------------------编程问答-------------------- 配置文件hibernate.cfg.xml
<property name="transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>
改成:
<property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
--------------------编程问答-------------------- 这个我试了,但是就提示我jndi命名的问题。
可是,这种模式,我在其他项目运行这好使,怎么在这里就不行呢? --------------------编程问答-------------------- 事物有异常。直接配置TransactionFactory不行吗?
--------------------编程问答-------------------- <session-factory>
<property name="hibernate.session_factory_name">HibernateSessionFactory</property>
<property name="hibernate.connection.datasource">jdbc/cosco</property>
<property name="show_sql">false</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.jdbc.fetch_size">50</property>
<property name="hibernate.jdbc.batch_size">50</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="hibernate.transaction.flush_before_completion">false</property>
<property name="hibernate.connection.release_mode">auto</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
这是我的hibernate.cfg.xml配置文件一部分 --------------------编程问答-------------------- 还有,我的配置信息和HibernateSessionFactory.class以及pojo都是在一个jar包中。
还有个业务jar包,是从那个jar包获得session和transaction的,应该不是这个问题吧,都是在一个容器下的。
补充:Java , Java EE