[英]Deploying on jboss using getCurrentSession
我已經在HibernateDAOFactory類中基於Link實現了DAO,有一種方法
protected Session getCurrentSession() {
return HibernateUtil.getSessionFactory().getCurrentSession();
}
為了實現相同的功能,我對hibernate.cfg.xml進行了更改,如以下文章中所述1在 這里2
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property><br/>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.current_session_context_class">thread</property>
在jboss上部署它時,出現以下錯誤
org.hibernate.TransactionException: could not register synchronization
我什至設置了屬性
<property name="hibernate.current_session_context_class">jta</property>
但我收到以下錯誤。
Caused by: org.hibernate.HibernateException: Unable to locate current JTA transaction
at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:88)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
我在這里想念什么嗎? 我的jboss版本是4.2.3,休眠版本是3.3.1,並使用Java 7。
對於基於線程的會話管理,我從hibernate.cfg.xml中刪除了transaction.factory_class
和manager_lookup_class
屬性,它的工作manager_lookup_class
。
但是對於基於jta的會話管理,我仍然遇到相同的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.