-->
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.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Could not register synchronization for container transaction
PostPosted: Fri May 14, 2010 8:44 am 
Newbie

Joined: Fri May 14, 2010 8:33 am
Posts: 8
Hi,

I wanted to add HibernateSearch to my application. But the indexing of the database fails.

I'm using EJB3, JTA, Hibernate3.5.1, Glassfish3

Here's my persistence.xml:
Code:
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="uwbedrijfsgids-ejbPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <!-- A list of vendor-specific properties -->
    <jta-data-source>comp/UserTransaction</jta-data-source>
    <properties>
      <property name="hibernate.cache.use_second_level_cache" value="true"/>
      <property name="hibernate.cache.use_query_cache" value="true"/>
      <property name="hibernate.cache.use_minimal_puts" value="true"/>
      <property name="hibernate.show_sql" value="false"/>

      <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
      <property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml"/>

      <property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
      <property name="hibernate.search.default.indexBase" value="/var/lucene/indexes"/>
    </properties>
  </persistence-unit>
</persistence>


When I try to launch initial indexing of the database in a SessionBean:

Code:
@Stateless
@LocalBean
public class HibernateSearchSessionBean implements Serializable{

    @PersistenceContext(unitName = "uwbedrijfsgids-ejbPU")
    private EntityManager em;

    public void launchIndexing() throws InterruptedException
    {
        FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
        fullTextEntityManager.createIndexer().startAndWait();
    }
}



I get the following exception:
Code:
SEVERE: org.hibernate.TransactionException: Could not register synchronization for container transaction
        at org.hibernate.transaction.CMTTransaction.begin(CMTTransaction.java:76)
        at org.hibernate.ejb.transaction.JoinableCMTTransaction.begin(JoinableCMTTransaction.java:89)
        at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1463)
        at org.hibernate.search.batchindexing.IdentifierConsumerEntityProducer.run(IdentifierConsumerEntityProducer.java:83)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)


Can someone help me?

Best regards,
Frederik


Last edited by fredje_2000 on Sat Jul 03, 2010 4:46 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sat May 15, 2010 2:42 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
it seems you're not having Hibernate linked to Glassfish's transactionmanager; I guess you need something like:
Code:
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" />


but let me know, I've no experience with Glassfish.

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


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sun May 16, 2010 8:28 am 
Newbie

Joined: Fri May 14, 2010 8:33 am
Posts: 8
Hi,

After adding this property the problem remains the same. :(


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sun May 16, 2010 9:52 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
a stacktrace? exactly the same?

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


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sun May 16, 2010 11:59 am 
Newbie

Joined: Fri May 14, 2010 8:33 am
Posts: 8
Hi Sanne, yes the stacktrace is exactly the same.


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sun May 16, 2010 5:27 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
<jta-data-source>comp/UserTransaction</jta-data-source>

I don't believe that's the correct datasource name

Quote:
Here's my persistance.xml:

I assume that's a typo for persistence.xml :)

Are you sure it's at all loading this configuration file?

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


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sat Jul 03, 2010 4:41 pm 
Newbie

Joined: Fri May 14, 2010 8:33 am
Posts: 8
Hi,

I ment persistence (i edited my post), sorry about that.
The jta-data-source name was correct... I've changed it to a better name in the meanwhile.

I'm sure the configuration is read because i see changes in the logging.
However i do get this message in the log during startup:
Code:
INFO org.hibernate.cfg.Environment - hibernate.properties not found

But i guess this is normal, seen we don't use a hibernate.properties .

In the log I also get:
Code:
INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory

Code:
INFO org.hibernate.transaction.TransactionManagerLookupFactory - instantiating TransactionManagerLookup: org.hibernate.transaction.SunONETransactionManagerLookup


So all that is ok I guess.
But I also get this, is this ok?
Code:
INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Mon Aug 16, 2010 4:23 am 
Newbie

Joined: Fri May 14, 2010 8:33 am
Posts: 8
After upgrading to HibernateSearch 3.2.1 the problem was solved

Thx for the replies


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Wed Aug 25, 2010 12:27 pm 
Newbie

Joined: Fri Oct 12, 2007 5:18 pm
Posts: 10
Hi,

I have the exact same problem:

- my persistence.xml is similar

Code:
<persistence-unit name="default" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/__default</jta-data-source>
        <jar-file>lib/my-model.jar</jar-file>
        <properties>
            <property name="hibernate.format_sql" value="false"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="false"/>
            <property name="hibernate.cache.use_second_level_cache" value="false" />
        </properties>
    </persistence-unit>


- my index code is similar

Code:
import org.hibernate.CacheMode;
import org.hibernate.search.jpa.Search;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class IndexServiceBean implements IndexService {

    @PersistenceContext(unitName = "default")
    private EntityManager em;

    @Override
    public void index() {
        try {
            Search.getFullTextEntityManager(em)
                    .createIndexer(MyClass.class)
                    .batchSizeToLoadObjects(25)
                    .cacheMode(CacheMode.IGNORE)
                    .threadsToLoadObjects(5)
                    .threadsForSubsequentFetching(5)
                    .startAndWait();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}


- I'm using glassfish v3.1b16 (I also tried on 3.1b11)

I'm using Hibernate Search 3.2.1.Final and yet, I have the same error:

Code:
[#|2010-08-25T11:58:07.091-0400|SEVERE|glassfish3.1|org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer|_ThreadID=472;_ThreadName=Hibernate Search: collectionsloader-2;|error during batch indexing:
org.hibernate.TransactionException: Could not register synchronization for container transaction
        at org.hibernate.transaction.CMTTransaction.begin(CMTTransaction.java:76)
        at org.hibernate.ejb.transaction.JoinableCMTTransaction.begin(JoinableCMTTransaction.java:89)
        at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1463)
        at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.run(EntityConsumerLuceneworkProducer.java:90)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
|#]


After debugging, it seems that the Search.getFullTextEntityManager(em) portion of the statement does create an entity manager whose transaction successfully joins the current one, but in the threads spawned by the indexer, the EntityConsumerLuceneworkProducer does a "session.beginTransaction()" and that's where it crashes. Did you have to do anything other than using the latest Hibernate Search version (3.2.1)?

Also, I'm confused about the following statement in the Hibernate Search documentation:

Quote:
The MassIndexer was designed for speed and is unaware of transactions, so there is no need to begin one or committing. Also because it is not transactional it is not recommended to let users use the system during it's processing, as it is unlikely people will be able to find results and the system load might be too high anyway.


I'm guessing they talk about the part where they manage the Lucene index because the part of the process that actually fetches the entities to index from the database does use a transaction (or at least, it appears each entity consumer thread is trying to create one).

Thank you very much.


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Tue Sep 28, 2010 9:24 am 
Newbie

Joined: Tue Sep 28, 2010 9:20 am
Posts: 6
I have the exact same problem using 3.2.1.Final.

Anyone?


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Tue Sep 28, 2010 1:25 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi jserdaru,
did you set the transaction manager lookup for Glassfish?
As I posted above in the same thread, you need to set:
Code:
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" />


Hi, ylazzari
could you try that too?
This appears to work for fredje_2000, I assume he had this options set as he has shown logs which point to the instantiation of the correct transaction manager lookup mechanism.

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


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sun Oct 03, 2010 3:17 pm 
Newbie

Joined: Sun Oct 03, 2010 2:26 pm
Posts: 1
I have the same problem. I am using Hibernate Search 3.2.1, and have all the parameters set to the values specified in the above posts in persistence.xml... But still the problem is repeating... We are using container managed transactions... In urgent need , any other things need to check with?

The below is my persistence.xml -

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd">
<persistence-unit name="LensooPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/vijay</jta-data-source>
<properties>
<property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
<property name="hibernate.search.default.indexBase" value="/usr/lensoo/lucene"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
<!-- <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />-->
<!-- <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory" />-->
</properties>
</persistence-unit>
</persistence>


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Fri Oct 08, 2010 8:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Could anyone put together a sample project exposing the problem and maybe attach it to an issue in http://opensource.atlassian.com/project ... se/HSEARCH. It would help to be able to reproduce this to track this further.

--Hardy


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Fri Dec 03, 2010 6:15 pm 
Newbie

Joined: Mon May 21, 2007 3:36 am
Posts: 16
Hi!

I'm experiencing the same problem using a Hibernate Search 3.3.0 CR1 MassIndexer on JBoss 6.0 CR1:
Quote:
ERROR [org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer] (Hibernate Search: collectionsloader-3) error during batch indexing: : org.hibernate.TransactionException: Could not register synchronization for container transaction
at org.hibernate.transaction.CMTTransaction.begin(CMTTransaction.java:76) [:3.6.0.Final]
at org.hibernate.ejb.transaction.JoinableCMTTransaction.begin(JoinableCMTTransaction.java:89) [:3.6.0.Final]
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473) [:3.6.0.Final]
at org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.run(EntityConsumerLuceneworkProducer.java:90) [:3.3.0.CR1]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_20]
at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

I could made it work by changing the transaction factory to "org.hibernate.transaction.JTATransactionFactory":
Code:
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />

Of course this is no solution as this does not work well in a CMP environment and produces warnings on every "ususal" entity manager operation:
Quote:
WARN [org.hibernate.ejb.AbstractEntityManagerImpl] (http-0.0.0.0-8080-1) Cannot join transaction: do not override hibernate.transaction.factory_class


Is there any progress on this issue? Should I pack an example EAR for JBoss?

_________________
Mario.


Top
 Profile  
 
 Post subject: Re: Could not register synchronization for container transaction
PostPosted: Sat Dec 04, 2010 7:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
winterer wrote:
Is there any progress on this issue? Should I pack an example EAR for JBoss?

Sure a example project exposing the problem would help. Attach it to a Jira issue and we will have a look at it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.