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.
Regards Micheal.Raj =================================================================== 27/12/2011: Update: Subject line is updated to reflect current problem Once the below property is changed to Weblogic, I am able to get the TransactionManager, but the error remains same:, Now the flow is going to the block "log.debug("no active transaction, could not register Synchronization");" from <prop key="hibernate.transaction.manager_lookup_class"> org.hibernate.transaction.JOTMTransactionManagerLookup </prop> To <prop key="hibernate.transaction.manager_lookup_class"> org.hibernate.transaction.WeblogicTransactionManagerLookup </prop>
public boolean registerSynchronizationIfPossible() { if ( isTransactionCallbackRegistered ) return true; TransactionManager tm = owner.getFactory().getTransactionManager(); if ( tm == null ) { return false; } else { try { javax.transaction.Transaction tx = tm.getTransaction(); if ( JTAHelper.isTransactionInProgress(tx) ) { tx.registerSynchronization( new CacheSynchronization(owner, this, tx, null) ); isTransactionCallbackRegistered = true; log.debug("successfully registered Synchronization"); return true; } else { log.debug("no active transaction, could not register Synchronization"); return false; } } catch (Exception e) { throw new TransactionException( "could not register synchronization with JTA TransactionManager", e ); } } }
Any thoughts here? Am I missing any more setups?
|