javaoracle-databasenullpointerexceptiontomcat6ucp

Oracle UCP and NullPointerException


I am trying to integrate Oracle Universal Connection Pool (UCP) with tomcat6. Server configuration is as following:

server.xml

<Resource name="jdbc/MyDB"
  auth="Container"
  factory="oracle.ucp.jdbc.PoolDataSourceImpl"
  type="oracle.ucp.jdbc.PoolDataSource"
  description="Oracle Universal Connection Pool"
  connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
  minPoolSize="1"
  maxPoolSize="5"
  inactiveConnectionTimeout="20"
  connectionPoolName="UCPPool"
  validateConnectionOnBorrow="true"
  sqlForValidateConnection="select 1 from DUAL"
  fastConnectionFailoverEnabled="true"
  onsConfiguration="nodes=test11grac1.example.com:6200,test11grac2.example.com:6200"
  user="test"
  password="XXXX"
  url="jdbc:oracle:thin:@test11g-cluster.example.com:1521/testdb"/>

context.xml

 <ResourceLink name="jdbc/MyDB" global="jdbc/MyDB" />

Initially this configuration worked well. Connections are distributed evenly across two RAC instances and when one instance went down all subsequent request directed to working one.

After a night of idle time all the requests to the connection pool caused the following exception:

Caused by: java.lang.NullPointerException: null
    at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.createOnePooledConnection(OracleJDBCConnectionPool.java:1260) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:339) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:168) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:143) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:157) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:931) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:873) ~[ucp.jar:11.2.0.3.0]
    at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:863) ~[ucp.jar:11.2.0.3.0]
    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46) ~[hibernate-entitymanager-3.4.0.GA.jar:3.4.0.GA]

What may cause this exception and is there any workaround?


Solution

  • After upgrading ojdbc6.jar and ucp.jar to their latest (12c) versions. Problem magically went away.