-->
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.  [ 7 posts ] 
Author Message
 Post subject: transaction error
PostPosted: Mon Apr 21, 2008 5:29 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
Hello
While using HS I receive an error
11:18:39,159 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_4] TwoPhaseCoordinator.afterCompletion - returned failure for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1ae130e

What does it mean and how to solve it?

Is there really a need to commit transaction if I only read (as in example below)? Anyway commenting tx.commit() doesn't help - error still exists

Code:
FullTextSession fullTextSession = Search.createFullTextSession(session);

Transaction tx = fullTextSession.beginTransaction();

MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{"summary", "body"},
  new StandardAnalyzer());
Query query = parser.parse( "Java rocks!" );
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, Book.class );
List result = hibQuery.list();
 
tx.commit();
session.close(); 


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 21, 2008 3:39 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

in which environment are you running? I assume JBoss/Seam, right? This particular waring message is not coming out of Hibernate or Hibernate Search, but is related to your database transaction setup. There is a Jboss Jira issue which has the same warning message (http://jira.jboss.com/jira/browse/EJBTHREE-898), but I am not sure whether it is related or what the warning means.

Either way, you definitely want to do the indexing within a transaction. The actual indexing work happens at commit time. However, that does not mean that you have to explicitly begin and commit a transaction. In many cases transactions will be handled by the container you are running in. Maybe you can post some of your code, for example where and how do you trigger this indexing processing?

--hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 8:09 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
I don't do any indexing, this error occurs everytime I search, and occurs after my method ends.
I saw this JIRA and seems it's the same bug, I hope they will repair it soon.
Below is skeleton of my code

Code:
@PersistenceContext
EntityManager em;


public Collection<Object[]> fullTextSearch(String searchPattern)
Analyzer queryAnalyzer = new SimpleAnalyzer();
QueryParser parser = new QueryParser(searchPattern, queryAnalyzer)
org.apache.lucene.search.Query luceneQuery = parser.parse(searchPattern);

Session session = (Session) em.getDelegate();
FullTextSession fts = Search.createFullTextSession(session);
org.hibernate.search.FullTextQuery query = fts.createFullTextQuery(luceneQuery, Person.class);
query.setProjection(FullTextQuery.THIS, FullTextQuery.DOCUMENT_ID,
            FullTextQuery.DOCUMENT, FullTextQuery.SCORE,
            FullTextQuery.BOOST);

query.setMaxResults(1000);
Collection<Object[]> lista = query.list();

fts.close();

return lista;



Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 10:27 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Don't know about that JIRA, but anyway
you shouldn't close the Session (you didn't open it..)

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 1:57 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
it's from example from documentation...
I do create fullTextSession, not open, maybe it's misunderstanding.
Anyway documentation is incomplete, it shouldn't suggest opening transaction when it's not needed nor suggest closing session if it's not opened.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 3:16 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
yes maybe the docs are not clear about this;
anyway the examples are not Seam-specific.

To clarify:
Code:
Search.createFullTextSession(session);

does not open a new session, it wraps the existing session to add additional functionality (fulltext search).
Se when you close() it your are going to close the one you got from the entitymanager; the lifecycle of this session is managed by the container.

Documentation examples are mostly about simple tests, not J2EE environments; it's simpler there, you don't open connections, you don't close them, you don't start transactions and don't need to commit.

Anyway, did you solve the problem removing the close() statement?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 5:43 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
No I'm going to sleep, and I will test it later at work ;)

Ok, it works, thank you :)


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