Results 1 to 4 of 4

Thread: NullPointerException in SessionFactoryUtils.doClose

  1. #1
    Join Date
    Aug 2004
    Posts
    16

    Default NullPointerException in SessionFactoryUtils.doClose

    Hi
    First off, I would like to express gratitude for such a great framework. It sure makes my life much easier.
    I am using Spring's Transaction and hibernate support with JOTM and Oracle. When I use Hibernate Template to access data in oracle via a SessionFactory, I get the following exception the first time only, After the first call, things work fine though. I do not have indepth knowledge of the spring code but suspect that it has to do with the way the sessionholder is managing sessions for jta transactions imho.
    java.lang.NullPointerException
    at org.springframework.orm.hibernate.SessionFactoryUt ils$SpringSessionSynchronization.beforeCommit(Sess ionFactoryUtils.java:620)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.triggerBeforeCommit(Abstr actPlatformTransactionManager.java:500)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:364)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:241)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:66)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :139)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
    at $Proxy0.add(Unknown Source)

    java.lang.NullPointerException
    at org.springframework.orm.hibernate.SessionFactoryUt ils.doClose(SessionFactoryUtils.java:548)
    at org.springframework.orm.hibernate.SessionFactoryUt ils.closeSessionOrRegisterDeferredClose(SessionFac toryUtils.java:537)
    at org.springframework.orm.hibernate.SessionFactoryUt ils.access$300(SessionFactoryUtils.java:85)
    at org.springframework.orm.hibernate.SessionFactoryUt ils$SpringSessionSynchronization.beforeCompletion( SessionFactoryUtils.java:647)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.triggerBeforeCompletion(A bstractPlatformTransactionManager.java:516)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:395)
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.doCommitTransactionAfterReturni ng(TransactionAspectSupport.java:241)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:66)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :139)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
    at $Proxy0.add(Unknown Source)

  2. #2
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    This seems to the same issue as reported in

    http://opensource.atlassian.com/proj...browse/SPR-272

    which unfortunately slipped into the 1.1 RC codebase. It should only occur with JTA and a TransactionManagerLookup in Hibernate configuration. Additionally, it seems that it just occurs when using pre-bound Sessions, like in the case of OpenSessionInViewFilter.

    In my comment for the JIRA issue above, I have suggested a patch that should solve this problem. If you have the chance to, please try it: Simply change your SessionFactoryUtils.java file accordingly and invoke "build alljars" in the Spring distribution root.

    Juergen

  3. #3
    Join Date
    Aug 2004
    Posts
    16

    Default Further session problem

    Thanks for the swift response.
    It seems, however, that SessionFactoryUtils.beforeCompletion calls Sessionholder.removeSession using the transaction as lookup key as well. There is no removeSession() in SessionHolder and the DEFAULT_KEY field in SessionHolder is private, hence cannot be used at this point to lookup the Session. How do you propose to solve this?
    Would it be a good idea to have SessionHolder's lookup methods use default key in case the supplied key fails? That should fix this problem for all clients of SessionHolder?

  4. #4
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    There's indeed a further fix necessary. Have a look at my latest comment in JIRA: JtaTransactionManager with a Hibernate TransactionManagerLookup should finally work now in the 1.1 codebase.

    Juergen

Similar Threads

  1. Replies: 1
    Last Post: Jul 27th, 2007, 12:30 AM
  2. Replies: 1
    Last Post: Sep 28th, 2005, 06:53 AM
  3. Replies: 7
    Last Post: Aug 16th, 2005, 05:54 AM
  4. Replies: 3
    Last Post: Jan 19th, 2005, 10:17 AM
  5. Replies: 2
    Last Post: Sep 3rd, 2004, 08:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •