-->
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: Transaction exception
PostPosted: Mon Jan 18, 2010 4:49 pm 
Beginner
Beginner

Joined: Wed Dec 16, 2009 10:34 am
Posts: 21
Hello:

I almost finish my application with hibernate search, but i got a little issue ;)
I got this message when using FullTextSession (with a HIbernateSession):

org.hibernate.TransactionException: Could not register synchronization for container transaction
at org.hibernate.transaction.CMTTransaction.begin(CMTTransaction.java:76)

However, when i use the FullTextSession inside a UserTransaction, works perfectly:

UserTransaction.begin();

updateIndex(); // Here i get the Session and create manually the indexes

UserTransaction.commit();

Does someone know what could be happening?


Top
 Profile  
 
 Post subject: Re: Transaction exception
PostPosted: Tue Jan 19, 2010 10:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Can you describe a little more your setup? Are you running in JBoss or any other container? Could you post your indexing code? Also UserTransaction.begin(); seems odd. You normally don't hard code in your application which type of transaction type you are using. You would configure the transaction factory and the do for example session.beginTransaction(). Or you would use declarative transactions.

--Hardy


Top
 Profile  
 
 Post subject: Re: Transaction exception
PostPosted: Tue Jan 19, 2010 11:50 am 
Beginner
Beginner

Joined: Wed Dec 16, 2009 10:34 am
Posts: 21
Hello:

I'm in glassfish 2.1 and JTA (I didn't tell you that, my bad !) and this is my index code :

Quote:


private void indexData(Object indexedClass,String fileUniqueKey)
{
FullTextSession fsession = Search.getFullTextSession(getHIbernateSession());
fsession.setFlushMode(FlushMode.MANUAL);
fsession.setCacheMode(CacheMode.IGNORE);

Class clss = Class.forName(indexedClass.getClass().getCanonicalName());

Criteria query = fsession.createCriteria(clss);

query.add(Restrictions.eq("uniqueTableKey", fileUniqueKey));

ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);

if (results != null)
{
Transaction tx = fsession.beginTransaction();
int index = 0;

while (results.next())
{
fsession.index(results.get(0));

if ((index % batch_zise) == 0)
{
fsession.flushToIndexes();
fsession.clear();
}
}

tx.commit();

Long endTime = System.currentTimeMillis();
getLog()
.log(
Level.INFO,
"Class " + clss.getName().toUpperCase() + " Indexed in: "
+ ((endTime - initTime) / 1000) + " SECS");
}
else
{
getLog()
.log(
Level.WARNING,
"NO SCROLLABLE RESULS IN CLASS " + clss.getName().toUpperCase());
}


I think i solved it anyway, initializing a new user transaction just before the index method and in the end of the method. But I'll appreciate if you tell me the reason of the exception..
Thanks.


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.