Announcement Announcement Module
Collapse
No announcement yet.
NullPointerException in SessionFactoryUtils.doClose Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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?

      Comment


      • #4
        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

        Comment

        Working...
        X