Announcement Announcement Module
Collapse
No announcement yet.
Null Pointer exception on closing Hibernate Session Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Null Pointer exception on closing Hibernate Session

    Hibernate version: Hibernate3-3.2.0

    Full stack trace of any exception that occurs:
    Code:
    12:17:59,968 ERROR [SessionFactoryUtils] Unexpected exception on closing Hibernate Session
    java.lang.NullPointerException
    	at org.hibernate.jdbc.AbstractBatcher.closeStatements(AbstractBatcher.java:310)
    	at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:376)
    	at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:318)
    	at org.hibernate.impl.SessionImpl.close(SessionImpl.java:298)
    	at org.springframework.orm.hibernate3.SessionFactoryUtils.doClose(SessionFactoryUtils.java:787)
    	at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSessionOrRegisterDeferredClose(SessionFactoryUtils.java:775)
    	at org.springframework.orm.hibernate3.SessionFactoryUtils.releaseSession(SessionFactoryUtils.java:748)
    	at org.springframework.orm.hibernate3.HibernateTransactionManager.doCleanupAfterCompletion(HibernateTransactionManager.java:662)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:754)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:541)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:473)
    	at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:267)
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
    	at $Proxy52.getFlightAvailabilityAndPrice(Unknown Source)
    	at com.tg.delegate.FlightSearchDelegate.getAvailability(FlightSearchDelegate.java:100)
    	at com.tg.controller.FlightSearchController.processFormSubmission(FlightSearchController.java:239)
    	at org.springframework.web.servlet.mvc.AbstractFormController.handleInvalidSubmit(AbstractFormController.java:649)
    	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:256)
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:358)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
    	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
    	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
    	at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
    	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:216)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
    	at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:108)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
    	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:195)
    	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
    	at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
    	at com.tg.acegi.FilterProxy.doFilter(FilterProxy.java:46)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
    	at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
    	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
    	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    	at java.lang.Thread.run(Thread.java:595)
    Name and version of the database you are using: mysql 5

    XML settings are following:
    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    	<property name="dataSource">
    		<ref local="dataSource"/>
    	</property>
    	<property name="hibernateProperties">
    		<props>
    			<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
    			<prop key="hibernate.show_sql">false</prop>
    		</props>
    	</property>
    	<property name="mappingResources">
    		<list>
    			<value>/com/tg/hbm/User.hbm.xml</value>		//other hbm xmls			
    		</list>
    	</property>
    </bean>
    
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory">
    <ref bean="sessionFactory"/>
    </property> 
    </bean>
    	
    <bean id= "hibernateSessionFactory" class="com.tg.hibernate.HibernateSessionFactory">
    	<property name="hibernateTemplate">
    		<ref bean="hibernateTemplate"/>
    	</property>
    </bean>	
    
    <bean id="tgBusinessServiceMgrTarget" class="com.tg.service.TGBusinessServiceMgrImpl">
    		<property name="pricingMgr">
    			<ref bean="flightPricingMgrImpl" />
    		</property>
    		<property name="flightAvailabilityMngr">
    			<ref bean="FlightAvailabilityMngr" />
    		</property>
    		<property name="paymentService">
    			<ref bean="paymentService" />
    		</property>
    		<property name="passengerManager">
    			<ref bean="passengerManager" />
    		</property>
    		<property name="flightBookingMgr">
    			<ref bean="flightBookingMgrImpl" />
    		</property>
    		<property name="pnrManager">
    			<ref bean="pnrManager" />
    		</property>
    		<property name="pnrUtil">
    			<ref bean="pnrUtil" />
    		</property>
    		<property name="smsAppMgr">
    			<ref bean="smsAppMgr" />
    		</property>
    	</bean>
    	
    	<bean id="tgTxnManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
         <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
    	
    	<bean id="smsAppMgr" class="com.tg.sms.SMSAppMgrImpl">
    	     <property name="smsDAO" ref="smsDAO"/>
        </bean>
    
    <bean id="tgBusinessServiceMgr"
          class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager" ref="tgTxnManager"/>
        <property name="target" ref="tgBusinessServiceMgrTarget"/>
        <property name="transactionAttributes">
          <props>
            <prop key="*">PROPAGATION_REQUIRED</prop>
          </props>
        </property>
      	</bean>
    Last edited by Ashish Jha; Jul 16th, 2007, 10:55 PM.

  • #2
    Code:
     
    public FlightResult getAvailability(final FlightSearchReq flightRequestBean, HttpSession session) 
    throws Exception { 
    
    /** Check for getBean.... */ 
    Map userInfoMap = new HashMap(); 
    if(session != null){ 
    Object userInfo = session.getAttribute(CommonSessionConstant.USER_INFO); 
    Object customerInfo = session.getAttribute(CommonSessionConstant.CUSTOMER_INFO); 
    userInfoMap.put(TGBusinessServiceConstants.USER_INFO, userInfo); 
    userInfoMap.put(TGBusinessServiceConstants.CUSTOMER_INFO, customerInfo); 
    } 
    
    FlightResult result = null; 
    try { 
    final List<FlightResult> flightResultList = this.tgBusinessServiceMgr 
    .getFlightAvailabilityAndPrice(flightRequestBean, userInfoMap); 
    
    if (flightResultList != null && flightResultList.size() > 0) { 
    result = convertToSingleFlightResult(flightResultList); 
    } 
    
    } catch (final Exception exception) { 
    TGLogger.error(this.getClass(), "getAvailability", exception); 
    throw exception; 
    } 
    return result; 
    
    } 
    
    code in TGBusinessServiceMgrImpl java class 
    
    
    /** 
    * @see com.tg.service.TGBusinessServiceMgr 
    * #getFlightAvailabilityAndPrice(com.tg.ws.FlightSearchReq, java.util.Map) 
    */ 
    public List<FlightResult> getFlightAvailabilityAndPrice( 
    final FlightSearchReq flightSearchRequest, final Map auditInfo) 
    throws TGBizServiceException { 
    
    TGLogger.debug(this.getClass(), "getFlightAvailabilityAndPrice", "START"); 
    final DurationEvent event = DurationEvent.fireStartMeasureEvent(this.getClass(), 
    "TGEngine:getFlightAvailabilityAndPrice", StringUtil.EMPTY_STRING); 
    List<FlightResult> flightResults = null; 
    try { 
    // Invoking the flight availability manager to serch for the available flights. 
    flightResults = this.flightAvailabilityMngr.getAvailability(flightSearchRequest); 
    
    // call pricing manager to calculate actual offer price by travel guru based on search. 
    if (flightResults != null) { 
    final int resultSize = flightResults.size(); 
    for (int i = 0; i < resultSize; i++) { 
    final FlightResult currentResult = flightResults.get(i); 
    
    final List<Product> onwardFlights = currentResult.getOnwardJourneyResp(); 
    final List<Product> validOnwardFlights = getValidFlightList(onwardFlights); 
    currentResult.setOnwardJourneyResp(validOnwardFlights); 
    if (validOnwardFlights != null 
    && validOnwardFlights.size() > 0) { 
    pricingMgr.getGrossFare(validOnwardFlights, auditInfo); 
    
    } 
    
    final List<Product> returnFlights = currentResult.getReturnJourneyResp(); 
    final List<Product> validReturnFlights = getValidFlightList(returnFlights); 
    currentResult.setReturnJourneyResp(validReturnFlights); 
    if (validReturnFlights != null 
    && validReturnFlights.size() > 0) { 
    pricingMgr.getGrossFare(validReturnFlights, auditInfo); 
    } 
    
    } 
    } 
    } catch (Exception exception) { 
    TGLogger 
    .error(this.getClass(), "getFlightAvailabilityAndPrice", exception.getMessage()); 
    throw new TGBizServiceException(exception); 
    } 
    DurationEvent.fireEndMeasureEvent(event); 
    TGLogger.debug(this.getClass(), "getFlightAvailabilityAndPrice", "END"); 
    
    return flightResults; 
    }
    Please help me

    Thanks in advance
    Last edited by Ashish Jha; Jul 16th, 2007, 10:53 PM.

    Comment


    • #3
      Please repost using [ code][/code ] tags. That way your post will be readable...

      Comment


      • #4
        [ code][ /code] tags without any space.

        Comment


        • #5
          I am really stuck here. Please help me. Thanks in Advance.

          Comment


          • #6
            I'd say it's a Hibernate bug. Try to use the newest Hibernate version.

            Comment


            • #7
              After changing to Hibernate version 3.2.4

              I have chenged the hibernate version form 3.2.2 to 3.2.4
              now I am getting following error.

              Code:
              12:40:46,580 WARN  [AbstractBatcher] Could not close a JDBC result set
              java.lang.NullPointerException
              	at org.hibernate.jdbc.AbstractBatcher.closeStatements(AbstractBatcher.java:314)
              	at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:382)
              	at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:324)
              	at org.hibernate.impl.SessionImpl.close(SessionImpl.java:298)
              	at org.springframework.orm.hibernate3.SessionFactoryUtils.doClose(SessionFactoryUtils.java:787)
              	at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSessionOrRegisterDeferredClose(SessionFactoryUtils.java:775)
              	at org.springframework.orm.hibernate3.SessionFactoryUtils.releaseSession(SessionFactoryUtils.java:748)
              	at org.springframework.orm.hibernate3.HibernateTransactionManager.doCleanupAfterCompletion(HibernateTransactionManager.java:662)
              	at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:754)
              	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:541)
              	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:473)
              	at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:267)
              	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
              	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
              	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
              	at $Proxy52.getFlightAvailabilityAndPrice(Unknown Source)
              	at com.tg.delegate.FlightSearchDelegate.getAvailability(FlightSearchDelegate.java:100)
              	at com.tg.controller.FlightSearchController.processFormSubmission(FlightSearchController.java:239)
              	at org.springframework.web.servlet.mvc.AbstractFormController.handleInvalidSubmit(AbstractFormController.java:649)
              	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:256)
              	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
              	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
              	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:723)
              	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:663)
              	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:394)
              	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:358)
              	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
              	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
              	at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
              	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
              	at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
              	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
              	at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:216)
              	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
              	at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:108)
              	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
              	at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:195)
              	at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
              	at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
              	at com.tg.acegi.FilterProxy.doFilter(FilterProxy.java:46)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
              	at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
              	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              	at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
              	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
              	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
              	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
              	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
              	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              	at java.lang.Thread.run(Thread.java:595)

              Comment


              • #8
                Could this be the same problem ?

                Comment


                • #9
                  Notice it's not an error anymore, it's a warning. If everything else works as expected you should be able to configure your logger to ignore it.

                  Comment


                  • #10
                    But will there be any performance issue or any other issue here if I ignore this as it throws error while closing session.

                    Comment


                    • #11
                      You will have to test it I'd say. But it's not an error, it's a warning.

                      Comment

                      Working...
                      X