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
|