NullPointerException when retrieving connections...... occurs occassionally
843859Jan 7 2008 — edited Nov 20 2014Hi everybody....
But, the same type of scenario happens for me with connections.
Let me explain more.....
We have three processes which will be running all the time on UNIX machines. When these processes start, the corresponding connection pool also is created using the OracleDataSource class. Connection pool is SAPERATE for all the three processes. No relationship between these three processes other than all these connection pools connect to the same database. we set the below properties for the OracleDataSource class
MinLimit: 3
MaxLimit: 15
defaultRowPrefetch: 10
When these processes run for some hours (say for 1 0r 2 days) one of these processes goes down. When I included more and more loggings, I came to know that the problem is coming when is getting NullPointerException at the time of establishing a connection.
Dec 18, 2007 2:31:24 PM com.merck.genesys.backoffice.applic.dmn.BaseDaemonApp run
FINE: ####java.lang.NullPointerException
at com.merck.genesys.persistence.StandardRowSet.getPreparedStatement(StandardRowSet.java:367)
at com.merck.genesys.persistence.StandardRowSet.setStringValue(StandardRowSet.java:408)
at com.merck.genesys.persistence.GenesysRowSet.setStringValue(GenesysRowSet.java:186)
at com.merck.genesys.persistence.GenesysTable.setWherePKValues(GenesysTable.java:710)
at com.merck.genesys.db.table.Table_DAEMON.selectByPK(Table_DAEMON.java:154)
at com.merck.genesys.backoffice.model.dao.Daemons.getRow(Daemons.java:294)
at com.merck.genesys.backoffice.applic.dmn.BaseDaemonApp.run(BaseDaemonApp.java:161)
at com.merck.genesys.backoffice.applic.dmn.DmnDataExchangeApp.main(DmnDataExchangeApp.java:32)
One more thing is.... among the three processes, one runs for every 6 hrs, second one runs for every 30 mins and third one runs for every 15 mins. We are getting the above issue only for the process which is running for every 15 mins. The same type of connection pooling mechanism is implemented for all the 3 processes.
After my analysis, I THINK, the issue is coming as some properties are missing for the OracleDataSource.... I mean,
The process is running fine for few hours. For the cycles during all these hours, when the process asks for connection from the pool, connection pool is establishing connections and providing the connection to the requested process from the pool. After using the connection, the corresponding process is closing the connection which is given back to the connection pool. I think, when the idle connections stay in the connection pool, some third party process (firewall/database settings) TERMINATING the connections which are already established. So, when the new process requests connection from the pool, connection pool is thinking that existing connection in the pool is GOOD and is handing over the existing connection (which was terminated by someother third party process -> stale connection) to the requested process. when my process tries to use this connection, it is getting exception saying NullPointerException.
Could you please confirm whether I am going in the right path so that I can proceed further?
If there is some other reason why this type of behaviour is shown, pls let me know so that it can be a great help for me to fix this issue.
I want to add the below properties to my OracleDataSource
InactivityTimeout: 20 (seconds)
ConnectionWaitTimeout: 10 (seconds)
ValidateConnection: true
ValidateConnectionStatement: select count(*) from dual
PropertyCheckInterval: 60
Waiting for ur response......