title: Glassfish RAR5058: Error while Resizing pool. Exception : null
body: <p>I am using GlassFish 3.1.1, SQL Server 2008, and NetBeans with Hibernate 3 and JSF 2.0 to create a web application. I am able to retrieve data with the hibernate API successfully but for some reason, the connection pool becomes null when I try to click a commandButton that takes me from one page to another page. In the action method, I am simply making a call to getOriginCount() but the hibernate API is giving a weird null error. Not sure if it's glassfish pool, hibernate, or sql server. </p>
  
  <pre><code>WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ perfpro-jdbc-pool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException
  WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: null]
  SEVERE: 1237767 [http-thread-pool-8080(2)] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
  
  SEVERE: 1237772 [http-thread-pool-8080(2)] ERROR org.hibernate.util.JDBCExceptionReporter - Error in allocating a connection. Cause: null
  
  WARNING: /cloneBuilderMenu.xhtml @31,168 rendered="#{cloneBuilderBean.canCreateMoreClones}": org.hibernate.exception.GenericJDBCException: Cannot open connection
  javax.el.ELException: /cloneBuilderMenu.xhtml @31,168 rendered="#{cloneBuilderBean.canCreateMoreClones}": org.hibernate.exception.GenericJDBCException: Cannot open connection
      at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
      at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:413)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1166)
      at javax.faces.component.UIForm.processDecodes(UIForm.java:225)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
      at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933)
      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
      at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
      at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
      at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
      at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
      at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
      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.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:344)
      at $Proxy146.beginTransaction(Unknown Source)
      at com.perpro.controller.dao.impl.AssessmentDaoImpl.getOriginCount(AssessmentDaoImpl.java:145)
      at com.perpro.controller.cloneBuilderBean.getCanCreateMoreClones(cloneBuilderBean.java:248)
      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 javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
      at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
      at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
      at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
      at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55)
      at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      ... 36 more
  Caused by: java.sql.SQLException: Error in allocating a connection. Cause: null
      at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:120)
      at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:92)
      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
      ... 60 more
  Caused by: javax.resource.spi.ResourceAllocationException: Error in allocating a connection. Cause: null
      at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:307)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:190)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:165)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:160)
      at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:113)
      ... 62 more
  Caused by: com.sun.appserv.connectors.internal.api.PoolingException
      at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:103)
      at com.sun.enterprise.resource.pool.ConnectionPool.addResource(ConnectionPool.java:282)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResourceAndAddToPool(ConnectionPool.java:1501)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResources(ConnectionPool.java:944)
      at com.sun.enterprise.resource.pool.ConnectionPool.resizePoolAndGetNewResource(ConnectionPool.java:792)
      at com.sun.enterprise.resource.pool.ConnectionPool.getResourceFromPool(ConnectionPool.java:760)
      at com.sun.enterprise.resource.pool.ConnectionPool.getUnenlistedResource(ConnectionPool.java:632)
      at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:526)
      at com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:381)
      at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:242)
      at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:167)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:338)
      at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:301)
      ... 66 more
  Caused by: com.sun.appserv.connectors.internal.api.PoolingException
      at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:924)
      at com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1185)
      at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:98)
      ... 78 more
  Caused by: java.lang.NullPointerException
      at com.microsoft.sqlserver.jdbc.FailoverMapSingleton.getFailoverInfo(FailOverMapSingleton.java:37)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:685)
      at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:593)
      at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:57)
      at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:113)
      at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)
      at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
      ... 80 more
  
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  WARNING: RAR5058: Error while Resizing pool perfpro-jdbc-pool. Exception : null
  </code></pre>
  
  <p>Here is the method where the nullpointer happens at session.beginTransaction(); The HibernateUtil class is generated by Netbeans.</p>
  
  <pre><code>public Integer getOriginCount() throws Exception {
          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
  
          session.beginTransaction();
  
          Integer originCount = ((Long) session.createQuery("select count(*) from origin").uniqueResult()).intValue();
          session.getTransaction().commit();
  
          return originCount;
      }
  </code></pre>