-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem with JTATransactionFactory
PostPosted: Mon Sep 11, 2006 3:08 am 
Newbie

Joined: Sat Sep 09, 2006 6:28 am
Posts: 4
Hi guys..

Some hibernate help required. We are trying to use CMT with WebLogic 8.1 and Hibernate 3.0 , but ran into some issues.
Hibernate version: 3.0


Listing down the doubts/queries that I have:

1. <property name="hibernate.transaction.factory_class"> . Should this be mapped to org.hibernate.transaction.CMTTransactionFactory or org.hibernate.transaction.JTATransactionFactory? Hibernate documentation says tha JTA can be used for both and CMT only for CMT. What is recommended best ?

2. When using CMTTransactionFactory and the property for lookup as:
<property name="hibernate.transaction.manager_lookup">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
we face the following error:

java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.ExceptionInInitializerError
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:290)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:248)
at com.eds.edscs.sam.wl.ejb.TestBean_kzv2am_EOImpl_815_WLStub.saveAddress(Unknown Source)
at com.eds.edscs.sam.wl.ejb.TestCISClient.main(TestCISClient.java:235)
Caused by: java.lang.ExceptionInInitializerError
at com.eds.edscs.sam.util.HibernateUtil.<clinit>(HibernateUtil.java:27)
at com.eds.edscs.sam.wl.ejb.CISInterfaceBean.saveAddress(CISInterfaceBean.java:62)
at com.eds.edscs.sam.wl.ejb.TestBean_kzv2am_EOImpl.saveAddress(TestBean_kzv2am_EOImpl.java:45)
at com.eds.edscs.sam.wl.ejb.TestBean_kzv2am_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:492)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:435)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:430)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1180)
at com.eds.edscs.sam.util.HibernateUtil.<clinit>(HibernateUtil.java:24)
... 12 more

What are we missing ?

Code for hibernate util
private static final SessionFactory sessionFactory;

static {
try {
/* Create the SessionFactory*/
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable throwable) {
System.out.println("Initial SessionFactory creation failed.");
throw new ExceptionInInitializerError(throwable);
}
}

public static final ThreadLocal session = new ThreadLocal();

/**
* This method returns the currentSession of the Thread.
* @return Session
* @throws HibernateException
*/
public static Session currentSession() throws HibernateException {
Session sessionNew = (Session) session.get();
/* Open a new Session, if this Thread has none yet*/
if (sessionNew == null) {
sessionNew = sessionFactory.openSession();
session.set(sessionNew);
}
return sessionNew;
}

/**
* This method close the session
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
s.getTransaction().commit();
session.set(null);
if (s != null)
s.close();
}




Any help in form of solutions, pointers etc would be gladly accepted.

Thanks
Rachit


Top
 Profile  
 
 Post subject: Adding the hibernate.cfg.xml
PostPosted: Mon Sep 11, 2006 3:19 am 
Newbie

Joined: Sat Sep 09, 2006 6:28 am
Posts: 4
I forgot to append the hibernate.cfg.xml, here it is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.datasource">/jdbc/Sam_data_source</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="showsql">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.transaction.manager_lookup">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="hibernate.current_session_context_class">jta</property>
<property name="cache.provider_class">
org.hibernate.cache.NoCacheProvider
</property>
<mapping resource="Address.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Solution
PostPosted: Thu Oct 05, 2006 2:02 am 
Newbie

Joined: Sat Sep 09, 2006 6:28 am
Posts: 4
Hi
After much deliberation, we found out that we need to set the following in the hibernate.cfg.xml for solving this:

<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>


This tells hibernate to use the container's transaction.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.