Reputation: 111
I am using Postgres database.Sometimes the connection closed automatically while interacting with my application.Sometimes even i am not interacting with my application sitting ideal at that time also connection closed.It shows follwing excepion.My server log is
SEVERE [org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable] (Thread-101) exception during job acquisition:
Error querying database. Cause: org.postgresql.util.PSQLException: This connection has been closed.
The error may exist in org/activiti/db/mapping/entity/Job.xml
The error may involve org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
The error occurred while executing a query
SQL: select RES.* from ACT_RU_JOB RES LEFT OUTER JOIN ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_ where (RES.RETR
IES_ > 0) and (RES.DUEDATE_ is null or RES.DUEDATE_ < ?) and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?) and ( (RES.EXECUTION_ID_
is null) or (PI.SUSPENSION_STATE_ = 1) ) LIMIT ? OFFSET ?
Cause: org.postgresql.util.PSQLException: This connection has been closed.: org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.postgresql.util.PSQLException: This connection has been closed.
The error may exist in org/activiti/db/mapping/entity/Job.xml
The error may involve org.activiti.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
The error occurred while executing a query
SQL: select RES.* from ACT_RU_JOB RES LEFT OUTER JOIN ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_ where (RES.RETR
IES_ > 0) and (RES.DUEDATE_ is null or RES.DUEDATE_ < ?) and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?) and ( (RES.EXECUTION_ID_
is null) or (PI.SUSPENSION_STATE_ = 1) ) LIMIT ? OFFSET ?
Cause: org.postgresql.util.PSQLException: This connection has been closed.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95) [mybatis-3.1.1.jar:3.1.1]
at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:301) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:292) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:287) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:274) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.persistence.entity.JobManager.findNextJobsToExecute(JobManager.java:105) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:50) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.cmd.AcquireJobsCmd.execute(AcquireJobsCmd.java:33) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:60) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32) [activiti-engine-5.11.jar:5.11]
at org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable.run(AcquireJobsRunnable.java:61) [activiti-engine-5.11.jar:5.11]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_32]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:714)
at org.postgresql.jdbc3.AbstractJdbc3Connection.prepareStatement(AbstractJdbc3Connection.java:274)
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.doPrepareStatement(BaseWrapperManagedConnection.java:677)
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:663)
at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:404)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:72) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:70) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) [mybatis-3.1.1.jar:3.1.1]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101) [mybatis-3.1.1.jar:3.1.1]
... 13 more
Upvotes: 1
Views: 6157
Reputation: 1
Issue can be solved by removing this option in default Activiti datasource configuration
<property name="defaultAutoCommit" value="false" />
Upvotes: 0
Reputation: 2195
I have had a similar problem using PHP. The cause of the problem was that I was nesting connections. The outer connection returned being closed after the inner connection had returned its data. The solution was simple: to process both connection serially, which meant in this case that I first executed the previously inner connection and afterwards the original outer connection.
Symbolically:
try{
firstConnection = createConnection();
results = firstConnection.query(...);
if results == true then
secondConnection = createConnection();
resultsToo = secondConnection.query();
if resultsToo == true then
processResults(resultsToo);
closeConnection();
end if;
processResults(results);
closeConnection();
end if;
exceptionHandling();
Processing the second connection before the first connection solved my issue.
Upvotes: 2