0 Replies Latest reply on Mar 15, 2010 7:05 AM by krishnapsg_1984

    JBOSS AS 4.2.2 throws org.jboss.util.NestedSQLException: No ManagedConnections available within configured blocking timeout ...

    krishnapsg_1984

      Hi

       

      I am having java 1.5.0 SE webservice client application which is running in a independent JVM, outside JBOSS AS 4.2.2 JVM, but makes use of JBOSS managed db connection pool by accessing datasource xml through jndi naming lookup via jnp url.

       

      I am frequently hitting with this exception, atleast once in a day in a production setup. Even after searching through internet for every possible details, I could not find any resolution.

       

      org.jboss.util.NestedSQLException: No ManagedConnections  available within configured blocking timeout ( 120000 [ms] ); - nested  throwable: (javax.resource.ResourceException: No ManagedConnections  available within configured blocking timeout ( 120000 [ms] ))

       

      and need to restart the jboss AS to resolve this issue.

       

      After thorough code review also, I could not find any unused db connection objects which are not closed.

       

      I: This is how i am getting db connection from java 1.5 SE:

      ========================================================

      public Connection getConnection(String logID) throws Exception {
              DataSource ds = null;
              Connection conn = null;
           
              // Create the initial context
              Hashtable<String,String> h = new Hashtable<String,String>();
              h.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
              h.put(Context.PROVIDER_URL, JNP_SERVER_HOST);
              Context ic = new InitialContext(h);

       

              ds = (DataSource) ic.lookup("NPSIGDS");
              if (ds!=null) {
               
                  // Create the connection
                  conn = ds.getConnection();
                  if(conn!=null) {
                      // Set the auto commit to false
                      conn.setAutoCommit(false);
                  } else {
                      logger.logMessage(logID, null, NPLogLevels.SEVERITY_ERROR, NPModuleNames.MODULE_NP_SIG, "DBConnectionManager:: getConnection():: Unable to create DB Connection");
                      throw new Exception("Unable to create DB connection");
                  }
              } else {
                  logger.logMessage(logID, null, NPLogLevels.SEVERITY_ERROR, NPModuleNames.MODULE_NP_SIG, "DBConnectionManager:: getConnection():: Failed to lookup for data source");
              }

              return conn;

          }

       

      ===========================================================

       

      II: And in each method where i getting db connection, i am closing the db objects in finally block:

      finally {
                  try {
                      if (rs != null) {
                          rs.close();
                          rs = null;
                      }
                      if (pstmt != null) {
                          pstmt.close();
                          pstmt = null;
                      }
                      if (conn != null) {
                          conn.close();
                          conn = null;
                      }
                  }

       

      ===================================

       

       

      III: Following values are put in  the data source xml which i am using:

       

       

      <min-pool-size>5</min-pool-size>
      <max-pool-size>50</max-pool-size>
      <idle-timeout-minutes>1</idle-timeout-minutes>

      <prepared-statement-cache-size>32</prepared-statement-cache-size>

      ========================================

       

      IV: I tried to debug by <track-statements>true</track-statements> in data source xml. And I got some exception stack trace mentioning unclosed result set and statement objects. But the exception stack trace is not having the pointer to the actual java source code.

      Is this jboss limitation for standalone JAVA SE application?

       

       

      ===========================================

       

      Pls provide your inputs on the issues and if there any suggestions, on how to resolve this.

       

      Thanks!