Hibernate Integration Without JNDI

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Hibernate Integration Without JNDI

greenbean
Hibernate Integration Without JNDI

I am running in to a problem with Hibernate locating the BTM UserTransaction in JNDI.  I dont see BTM registering the UserTransaction in JNDI.  I did see the discussion here:  http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739

However, I am having a little trouble understanding why I need JNDI when using Spring.  Is it possible to configure Hibernate and Bitronix to work together without JNDI?  I tried various configuration options, however, I am always get the error where Hibernate cannot locate UserTransaction in JNDI.  I do have JNDI available since I am using JBoss.  However, I would prefer maintaining the configuration only in Spring if possible.

I pass a transaction manager reference to the session factory bean.  However, it still insists on doing the lookup.  Do you have any suggestions?

     <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">

          <property name="properties">

               <props>

                    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>

                    <prop key="hibernate.show_sql">false</prop>

                    <prop key="hibernate.cache.use_second_level_cache">true</prop>

                    <prop key="hibernate.cache.use_query_cache">true</prop>

                    <prop key="hibernate.connection.isolation">3</prop>

                    <prop key="hibernate.current_session_context_class">jta</prop>

                    <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>

                    <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>

                    <prop key="jta.UserTransaction">BTMUserTransaction</prop>

                    <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</prop>

               </props>

          </property>

     </bean>

     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

          <property name="dataSource">

               <ref bean="pgDataSource" />

          </property>

          <property name="hibernateProperties">

               <ref bean="hibernateProperties" />

          </property>

          <property name="jtaTransactionManager" ref="transactionManagerImpl" />

     </bean>

Reply | Threaded
Open this post in threaded view
|

Re: Hibernate Integration Without JNDI

snicoll
Which version of Hibernate are you using?

Yes it is possible to use hibernate, spring and bitronix without JNDI.
I have a project sample I will post on a blog entry soon.

S.

On Wed, Dec 15, 2010 at 7:08 PM, Urciolo, Kevin J (IS)
<[hidden email]> wrote:

> I am running in to a problem with Hibernate locating the BTM UserTransaction
> in JNDI.  I don’t see BTM registering the UserTransaction in JNDI.  I did
> see the discussion here:
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739
>
> However, I am having a little trouble understanding why I need JNDI when
> using Spring.  Is it possible to configure Hibernate and Bitronix to work
> together without JNDI?  I tried various configuration options, however, I am
> always get the error where Hibernate cannot locate UserTransaction in JNDI.
> I do have JNDI available since I am using JBoss.  However, I would prefer
> maintaining the configuration only in Spring if possible.
>
> I pass a transaction manager reference to the session factory bean.
> However, it still insists on doing the lookup.  Do you have any suggestions?
>
>      <bean id="hibernateProperties"
> class="org.springframework.beans.factory.config.PropertiesFactoryBean">
>
>           <property name="properties">
>
>                <props>
>
>                     <prop
> key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
>
>                     <prop key="hibernate.show_sql">false</prop>
>
>                     <prop
> key="hibernate.cache.use_second_level_cache">true</prop>
>
>                     <prop key="hibernate.cache.use_query_cache">true</prop>
>
>                     <prop key="hibernate.connection.isolation">3</prop>
>
>                     <prop
> key="hibernate.current_session_context_class">jta</prop>
>
>                     <prop
> key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
>
>                     <prop
> key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
>
>                     <prop
> key="jta.UserTransaction">BTMUserTransaction</prop>
>
>                     <prop
> key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</prop>
>
>                </props>
>
>           </property>
>
>      </bean>
>
>      <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>
>           <property name="dataSource">
>
>                <ref bean="pgDataSource" />
>
>           </property>
>
>           <property name="hibernateProperties">
>
>                <ref bean="hibernateProperties" />
>
>           </property>
>
>           <property name="jtaTransactionManager"
> ref="transactionManagerImpl" />
>
>      </bean>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL:Re: [btm-user] Hibernate Integration Without JNDI

greenbean
I am currently using Hibernate 3.3.1.  I could upgrade to a newer version if that would help.

Any chance you could email me the project sample?

Thanks,

Kevin

-----Original Message-----
From: Stephane Nicoll [mailto:[hidden email]]
Sent: Wednesday, December 15, 2010 2:11 PM
To: [hidden email]
Subject: EXTERNAL:Re: [btm-user] Hibernate Integration Without JNDI

Which version of Hibernate are you using?

Yes it is possible to use hibernate, spring and bitronix without JNDI.
I have a project sample I will post on a blog entry soon.

S.

On Wed, Dec 15, 2010 at 7:08 PM, Urciolo, Kevin J (IS)
<[hidden email]> wrote:

> I am running in to a problem with Hibernate locating the BTM UserTransaction
> in JNDI.  I don't see BTM registering the UserTransaction in JNDI.  I did
> see the discussion here:
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739
>
> However, I am having a little trouble understanding why I need JNDI when
> using Spring.  Is it possible to configure Hibernate and Bitronix to work
> together without JNDI?  I tried various configuration options, however, I am
> always get the error where Hibernate cannot locate UserTransaction in JNDI.
> I do have JNDI available since I am using JBoss.  However, I would prefer
> maintaining the configuration only in Spring if possible.
>
> I pass a transaction manager reference to the session factory bean.
> However, it still insists on doing the lookup.  Do you have any suggestions?
>
>      <bean id="hibernateProperties"
> class="org.springframework.beans.factory.config.PropertiesFactoryBean">
>
>           <property name="properties">
>
>                <props>
>
>                     <prop
> key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
>
>                     <prop key="hibernate.show_sql">false</prop>
>
>                     <prop
> key="hibernate.cache.use_second_level_cache">true</prop>
>
>                     <prop key="hibernate.cache.use_query_cache">true</prop>
>
>                     <prop key="hibernate.connection.isolation">3</prop>
>
>                     <prop
> key="hibernate.current_session_context_class">jta</prop>
>
>                     <prop
> key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
>
>                     <prop
> key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
>
>                     <prop
> key="jta.UserTransaction">BTMUserTransaction</prop>
>
>                     <prop
> key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</prop>
>
>                </props>
>
>           </property>
>
>      </bean>
>
>      <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
>
>           <property name="dataSource">
>
>                <ref bean="pgDataSource" />
>
>           </property>
>
>           <property name="hibernateProperties">
>
>                <ref bean="hibernateProperties" />
>
>           </property>
>
>           <property name="jtaTransactionManager"
> ref="transactionManagerImpl" />
>
>      </bean>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: EXTERNAL:Re: [btm-user] Hibernate Integration Without JNDI

Ludovic Orban
Administrator
It's not BTM which requires JNDI but Hibernate. There is a way to work around it but this requires sublassing Hibernate's JTATransactionFactory. I may consider it in the future as the BTM build is now modularized.

As of today, you have to configure these properties in your hibernateProperties Spring bean:

<prop key="jta.UserTransaction">BTMUserTransaction</prop>
<prop key="hibernate.jndi.class">bitronix.tm.jndi.BitronixInitialContextFactory</prop>

and this one in your btmConfig bean:

<property name="jndiUserTransactionName" value="BTMUserTransaction" />

and remember to use the TransactionManagerLookup implementation documented in http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739 and NOT the one included with Hibernate.
Reply | Threaded
Open this post in threaded view
|

RE: RE: EXTERNAL:Re: [btm-user] Hibernate Integration Without JNDI

greenbean
I can confirm that the Bitronix Transaction Manager version
2.1.1-BTM-99-SNAPSHOT corrects the issue I was having with Apache Camel
Integrations.

Kevin

-----Original Message-----
From: Ludovic Orban [mailto:[hidden email]]
Sent: Wednesday, December 15, 2010 3:40 PM
To: [hidden email]
Subject: [btm-user] RE: EXTERNAL:Re: [btm-user] Hibernate Integration
Without JNDI


It's not BTM which requires JNDI but Hibernate. There is a way to work
around
it but this requires sublassing Hibernate's JTATransactionFactory. I may
consider it in the future as the BTM build is now modularized.

As of today, you have to configure these properties in your
hibernateProperties Spring bean:

<prop key="jta.UserTransaction">BTMUserTransaction</prop>
<prop
key="hibernate.jndi.class">bitronix.tm.jndi.BitronixInitialContextFactor
y</prop>

and this one in your btmConfig bean:

<property name="jndiUserTransactionName" value="BTMUserTransaction" />

and remember to use the TransactionManagerLookup implementation
documented
in http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739
and
NOT the one included with Hibernate.
--
View this message in context:
http://old.nabble.com/Hibernate-Integration-Without-JNDI-tp30466401p3046
7714.html
Sent from the Bitronix Transaction Manager mailing list archive at
Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email