-->
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.  [ 2 posts ] 
Author Message
 Post subject: org.hibernate.TransactionException
PostPosted: Fri Jan 19, 2007 9:48 am 
Newbie

Joined: Fri Jan 19, 2007 9:13 am
Posts: 1
I'm running a test case which tests my application's hibernate stuff which is deployed on a Weblogic 8.1 server.

here is the setup method

private Session session;
private Transaction t;

protected void setUp() throws Exception {
Configuration config = new Configuration();
config.configure();
SessionFactory sessionFactory = config.buildSessionFactory();
session = sessionFactory.openSession();
t = session.beginTransaction();
}


While doing a session.beginTransaction i get the following error.


org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:187)
at org.hibernate.transaction.JTATransaction.begin(JTATransaction.java:89)
at org.hibernate.transaction.JTATransactionFactory.beginTransaction(JTATransactionFactory.java:53)
at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:271)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1079)
at castle.server.hbm.biz.visitor.TestCore2Hbm.setUp(TestCore2Hbm.java:25)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: javax.transaction.SystemException: You may enlist a resource only on a server
at weblogic.transaction.internal.TransactionImpl.registerSynchronization(TransactionImpl.java:494)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:176)
... 15 more


The hibernate.cfg.xml file is as under
--------------------------------------------------


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

<hibernate-configuration>
<session-factory>

<!-- local connection properties -->

<property name="hibernate.jndi.url">
t3://localhost:7001
</property>


<property name="hibernate.jndi.class">
weblogic.jndi.WLInitialContextFactory
</property>

<property name="hibernate.connection.datasource">
castle/datasources/castle
</property>

<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>

<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.WeblogicTransactionManagerLookup
</property>

<!-- This is required for weblogic! -->
<property name="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</property>

<!-- These are tunning properties set by Romulus after some tests.
Please don't change these values whithout talking with Romulus!!!! -->
<property name="hibernate.max_fetch_depth">5</property>
<property name="hibernate.default_batch_fetch_size">250</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>


<!-- cache settings -->
<property name="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</property>
<property name="hibernate.cache.use_query_cache">true</property>


Please, help me to solve this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 11:01 am 
Beginner
Beginner

Joined: Tue May 23, 2006 4:10 pm
Posts: 38
Location: Charleston, SC
I included the relevant settings from our hibernate config file. We use WLS 8.1 SP6.

Code:
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">
  jta
</property>

<!-- Transaction management -->
<property name="hibernate.transaction.factory_class">
  org.hibernate.transaction.CMTTransactionFactory
</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.connection.release_mode">
  auto
</property>
<property name="hibernate.order_updates">
  true
</property>


Try changing the transaction factory class from JTATransactionFactory to CMTTransactionFactory:

<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>

<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.CMTTransactionFactory
</property>

And adding:

<property name="current_session_context_class">
jta
</property>

Retest calling getCurrentSession() instead of openSession() and post your results. Also, please let us know what version of Hibernate you are using. I seem to remember a similar problem in our environment when we tried a release candidate of Hibernate 3.2. We are currently using Hibernate 3.1.

Grant


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.