Your driver may not support getAutoCommit() or setAutoCommit()

Hello,

We are running Camunda Engine on Centos 7.5 with Postgresql.
We got this error randomly:

SEVERE [http-nio-8081-exec-9] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context:
### Error querying database.  Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: org.postgresql.util.PSQLException: This connection has been closed.
### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/HistoricProcessInstance.xml
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstanceCountByQueryCriteria
### The error occurred while executing a query
### Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit.  Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false.  Cause: org.postgresql.util.PSQLException: This connection has been closed.

The database configuration:

<Resource name="jdbc/ProcessEngine"
              auth="Container"
              type="javax.sql.DataSource"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
              uniqueResourceName="process-engine"
              driverClassName="org.postgresql.Driver"
              url="jdbc:postgresql://xxxxxxxxxx.rds.amazonaws.com:5432/camunda"
              defaultTransactionIsolation="READ_COMMITTED"
              username="camunda"
              password="xxxxxxxxx"
              maxActive="20"
              minIdle="5"
              maxIdle="20" />

Can you help me please?

Regards,
Bilel.

Hi Bilel,

Please check your if your database has the correct isolation level configured.
https://docs.camunda.org/manual/7.11/user-guide/process-engine/database/#isolation-level-configuration

If it is the case, please provide us the details of your db - version, driver version.

Best,
Yana

Hello @Yana ,

We got the same problem again.

Here some details:

  • JDBC connector: postgresql-42.2.8.jar
  • PostgreSQL 11.4

Thanks for your help.
Bilel.

Hi @Bilel_BARHOUMI,

I have to ask again for the isolation level.
And keep in mind that we don’t support PostgreSQL version 11.4, so we didn’t test it.
https://docs.camunda.org/manual/7.12/introduction/supported-environments/

Best regards,
Yana

Hi @Bilel_BARHOUMI,

Could you also check how the connection pool in configured?
Make sure that the following is configured:

testOnBorrow="true"
validationQuery="SELECT 1"
validationInterval="34000" 

Best,
Michal

2 Likes

We have the same issue

Camunda 7.12 (camunda-bpm-platform:tomcat-7.12.0)

<Resource name="jdbc/ProcessEngine" auth="Container" type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" uniqueResourceName="process-engine" driverClassName="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}" defaultTransactionIsolation="READ_COMMITTED" testOnBorrow="true" removeAbandoned="true" removeAbandonedTimeout="60" validationQuery="SELECT 1" validationInterval="30000" maxActive="20" minIdle="5" />

Postgresql 9.6.15
JDBC connector: postgresql-9.3-1102-jdbc4.jar

We have the same issue

  • PostgreSQL 11.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
  • JDBC connector: postgresql-42.2.9.jar
  • Camunda BPM platform v7.12.0

@Abu_Man have you configured the connection pool settings? maybe a solution would be to use a connection pool which has a keep-alive option for connections. I think the problem is that inactive connections are closed by the server and this leads to this problems.


Refer this solution:

Mybatis error resolution: Your driver may not support getAutoCommit() or setAutoCommit()

Effect Of Connection.setAutoCommit(…) method in JDBC


 protected void setDesiredAutoCommit(boolean desiredAutoCommit) {
    try {
      if (connection.getAutoCommit() != desiredAutoCommit) {
        if (log.isDebugEnabled()) {
          log.debug("Setting autocommit to " + desiredAutoCommit + " on JDBC Connection [" + connection + "]");
        }
        connection.setAutoCommit(desiredAutoCommit);
      }
    } catch (SQLException e) {
      // Only a very poorly implemented driver would fail here,
      // and there's not much we can do about that.
      throw new TransactionException("Error configuring AutoCommit.  "
          + "Your driver may not support getAutoCommit() or setAutoCommit(). "
          + "Requested setting: " + desiredAutoCommit + ".  Cause: " + e, e);
    }
  }

The following setting fixed the issue for us (Camunda BPM 7.12):

    <Resource name="jdbc/ProcessEngine" auth="Container" type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" uniqueResourceName="process-engine" driverClassName="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}" 
defaultTransactionIsolation="READ_COMMITTED" 
testOnBorrow="true" 
removeAbandoned="true" 
testWhileIdle="true" 
removeAbandonedTimeout="60" 
validationQuery="SELECT 1"
timeBetweenEvictionRunsMillis="30000"
minEvictableIdleTimeMillis="30000"
validationInterval="30000" 
maxActive="20" 
minIdle="5" />

It was not used in Camunda BPM 7.9

1 Like

Hi,
we run camunda 7.13 docker image in Openshift with postgres 10 database
and experienced the same issue.
We fixed it in same way as @Olivier_Albertini did but in containerized way:
adding DB_VALIDATE_ON_BORROW=true to container environment.

Hi,

same problem with camunda 7.14, with MariaDB up to date on virtual machine (with the isolation level READ_COMMITTED).
Applying settings like @Olivier_Albertini fixes issue for us. I tested it after by provoking the same error to test the solution.