This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JDBCContext returning TransactionManager as null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JDBCContext returning TransactionManager as null" Watch "JDBCContext returning TransactionManager as null" New topic
Author

JDBCContext returning TransactionManager as null

Danny Vittal
Greenhorn

Joined: Feb 24, 2005
Posts: 10
I am trying to migrate Spring/Hibernate application from 0C4J to Weblogic Application Server.

Please find the stacktrace below:

java.lang.NullPointerException
at org.hibernate.engine.query.QueryPlanCache$HQLQueryPlanKey.<init>(QueryPlanCache.java:169)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:64)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at com.iba.framework.core.pojo.dao.DAOImpl.findByQuery(DAOImpl.java:131)
at com.iba.framework.lookup.pojo.dao.LookupDAOImpl.lookupByQuery(LookupDAOImpl.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:104)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.aop.interceptor.PerformanceMonitorInterceptor.invokeUnderTrace(PerformanceMonitorInterceptor.java:60)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.aop.interceptor.SimpleTraceInterceptor.invokeUnderTrace(SimpleTraceInterceptor.java:59)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:110)
at org.springframework.aop.interceptor.DebugInterceptor.invoke(DebugInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
at $Proxy70.lookupByQuery(Unknown Source)

Analysis:

Hibernate Version: 3.1.2
Spring Version: 2.0.2
Application Server: WebLogic Server Version: 10.3.5.0
Database: Oracle 10g Release 2

I added the hibernate source at runtime to see where exactly the code is failing and found the below method ib hibernate jar:

Class Name: org.hibernate.jdbc.JDBCContext
Method: registerSynchronizationIfPossible() the following line owner.getFactory().getTransactionManager() returns null.

Lines extracted from hibernate code:

public boolean registerSynchronizationIfPossible() {
if ( isTransactionCallbackRegistered ) return true;
TransactionManager tm = owner.getFactory().getTransactionManager(); ------> returns null.
if ( tm == null ) {
return false;
}


extracts from spring-orm.xml for the transaction related attributes:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>

<prop key="jta.UserTransaction">
java:comp/UserTransaction
</prop>
<prop
key="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.JOTMTransactionManagerLookup
</prop>
<prop key="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</prop>
</bean>
---------------
<bean id="txManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
</bean>
----------------
<bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="txManager" />
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED,timeout_5000</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="record*">PROPAGATION_REQUIRED</prop>
<prop key="set*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
---------------------------
<bean name="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
-----------------------
I am new to Spring/Hibernate, any help is highly appreciated.
 
Don't get me started about those stupid light bulbs.
 
subject: JDBCContext returning TransactionManager as null
 
Similar Threads
spring 2 with hibernate 3
Hibernate insert fails due to generate key failure
How to wire-up TransactionProxyFactoryBean & HibernateInterceptor ?
unsatisfied Dependancy exception
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)