4

I am using Oracle UCP (Universal Connection Pool). I am getting the following error after processing around 100K records.

    oracle.ucp.UniversalConnectionPoolException: Invalid life cycle state. Check the status of the Universal Connection Pool
        at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:488) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:163) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:943) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:873) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
        at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:863) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
 Caused by: oracle.ucp.UniversalConnectionPoolException: Invalid life cycle state. Check the status of the Universal Connection Pool
            at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:368) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:49) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:80) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:131) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:304) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:168) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:143) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:157) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:931) ~[ucp-11.2.0.3.0.jar:11.2.0.3.0]
            ... 15 more

Here is the code snippet to create the DataSource

PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();


    dataSource.setURL("jdbc.url"));
    dataSource.setUser("jdbc.user"));
    dataSource.setPassword("jdbc.password"));
    dataSource.setMaxConnectionReuseCount(100);

    dataSource.setInitialPoolSize(50);
    dataSource.setMinPoolSize(50);

    dataSource.setMaxPoolSize(100);

    dataSource.setValidateConnectionOnBorrow(true);

    dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");

And then I get the connection from data source as

datasource.getConnection();
Amr Eladawy
  • 4,193
  • 7
  • 34
  • 52
  • This could be a bug in the UCP and JDBC version you're using. You might want to try the latest version 12.1.0.2. Note that you need to upgrade both the JDBC jar and the UCP jar. – Jean de Lavarene Oct 05 '16 at 08:22
  • I am using UCP 11.2.0.3 and the latest is 11.2.0.4 as per this link. http://www.oracle.com/technetwork/database/enterprise-edition/downloads/ucp-112010-099129.html where can I get that version 12.1.0.2 – Amr Eladawy Oct 05 '16 at 08:29
  • The 12.1.0.2 download page is there: http://www.oracle.com/technetwork/database/features/jdbc/default-2280470.html – Jean de Lavarene Oct 05 '16 at 08:47
  • I had the same problem because of InitialPoolSize=0. I have set InitialPoolSize=1 and after was everything OK. – Michal Sipek Nov 15 '17 at 14:31

2 Answers2

0

In my case, I was using wrong password :|

Abdul Mohsin
  • 1,253
  • 1
  • 13
  • 24
0

In my case I encountered this exception during a routine upgrade of a tomcat application. When attempting to interact with an Oracle database (and so getting a connection from the UniversalConnectionPool) the application kept getting this exception.

After reading up on the UniversalConnectionPool (overview-using-ucp-manager), I found this line in some Oracle documentation: "a life cycle state exception occurs if an application attempts to start a pool that has been previously started or if the pool is in a state other than stopped or failed." That is the closest thing I could find for something related to this exception.

I ended up finding that a mistake in my build config meant that I have an OJDBC driver placed in both my application and externally in the Tomcat and somehow these were then interacting with my datasource and the UCP together at the same time, causing the one initialized last to give this error. Removing the OJDBC driver from the classpath in my application fixed the issue.

Thomas
  • 1
  • 1