-->
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.  [ 1 post ] 
Author Message
 Post subject: TransactionManager not injected in HibernateSearch with JOTM
PostPosted: Fri Feb 01, 2013 4:09 am 
Newbie

Joined: Tue Jan 29, 2013 6:30 am
Posts: 3
Hello,

Following is my context -
I have a JSF-Spring-JPA-Hibernate based web application that I am trying to deploy in Tomcat. The JPA transcations do work properly in Glassfish - I am able to do CRUD through UI, but I have problems when I try to migrate my application into Tomcat (with JOTM configured).

I have following versions-
Hibernate core - 3.6.10.Final
Hibernate search -3.1.1.GA
jotm-core - 2.2.3

Key Configurations
1.
.......
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="EDMPersistenceUnit" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />

</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="javax.persistence.transactionType">jta</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</prop>
<!-- <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</prop> -->
<prop key="jta.UserTransaction">java:comp/UserTransaction</prop>
<prop key="hibernate.transaction.flush_before_completion">true</prop>
<!--<prop key="hibernate.transaction.auto_close_session">true</prop>-->
<prop key="hibernate.current_session_context_class">org.hibernate.context.JTASessionContext</prop>
<prop key="hibernate.connection.release_mode">after_statement</prop>

</props>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
</property>
</bean>
.....


<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionSynchronizationRegistryName" value="java:comp/env/TransactionSynchronizationRegistry"/>
<property name="transactionManagerName" value="java:comp/UserTransaction"/>
<property name="allowCustomIsolationLevels" value="true"></property>
</bean>

<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/EDM" resource-ref="true"/>
...

At runtime ,I get following exception while doing an insert/update -
Caused by: java.lang.IllegalStateException: JTA TransactionManager not available

at org.hibernate.transaction.JTATransaction.registerSynchronization(JTAT
ransaction.java:302)
at org.hibernate.search.backend.impl.EventSourceTransactionContext.regis
terSynchronization(EventSourceTransactionContext.java:56)
at org.hibernate.search.backend.impl.TransactionalWorker.performWork(Tra
nsactionalWorker.java:47)
at org.hibernate.search.event.FullTextIndexEventListener.processWork(Ful
lTextIndexEventListener.java:128)
at org.hibernate.search.event.FullTextIndexEventListener.onPostInsert(Fu
llTextIndexEventListener.java:109)
at org.hibernate.action.EntityIdentityInsertAction.postInsert(EntityIden
tityInsertAction.java:90)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentit
yInsertAction.java:66)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplic
ate(AbstractSaveEventListener.java:290)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(Abstrac
tSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:108)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(
EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient
(DefaultPersistEventListener.java:131)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(Default
PersistEventListener.java:87)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(Default
PersistEventListener.java:38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityMan
......

Looking at the source code for org.hibernate.transaction.JTATransaction, I can figure out that it is not having the reference of Transaction Manager and thats why it is failing.

What I can not figure out it why this works pretty well in Glassfish (when using default TM of Glassfish) and fails in Tomcat.

Is there any hibernate-search property I am missing or is the problem with JOTM?

Would appreciate if someone can throw some light on this.

Thnaks,
Jatin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.