How to add 'testOnBorrow' & 'validationQuery' in camunda docker version

I am using camunda docker version (image - camunda/camunda-bpm-platform:latest) and mysql as the process engine db. Getting persistence exception sometimes in camunda log.
I found from the forum that these 2 below parameters need to be added in server.xml file of tomcat.

testOnBorrow=“true”;
validationQuery=“SELECT 1”;

so, my understanding is – the updated server.xml of tomcat should look like below.

I executed the below command-

docker run -d --name camunda -p 8080:8080 --link mysql
-e DB_DRIVER= com.mysql.jdbc.Driver
-e DB_URL= jdbc:mysql://test-mysql002:3306/processengine?autoReconnect=true
-e DB_USERNAME=camunda
-e DB_PASSWORD=camunda
-e WAIT_FOR= test-mysql002:3306
-e DB_VALIDATE_ON_BORROW=true
-e DB_VALIDATION_QUERY=SELECT 1
camunda/camunda-bpm-platform:latest

And found the updated server.xml as below –

<Resource name=“jdbc/ProcessEngine” auth=“Container” type=“javax.sql.DataSource” factory=“org.apache.tomcat.jdbc.pool.DataSourceFactory” uniqueResourceName=“process-engine” driverClassName=“com.mysql.jdbc.Driver” url=“jdbc:mysql://test-mysql002:3306/processengine?autoReconnect=true” defaultTransactionIsolation=“READ_COMMITTED” username=“camunda” password=“camunda” maxActive=“20” minIdle=“5” maxIdle=“20”/ >

I could not find testOnBorrow and validationQuery attribute here.

Please suggest what steps exactly need to follow for this. Or I am doing anything wrong.
Thanks

2 Likes

I’m also wondering the same thing.

(actually I’m also suggesting this should be default configuration)

This is how we do it in Docker/Kubernetes: https://about.lovia.life/docs/infrastructure/camunda/#kubernetes-deployment

Hope this helps for someone looking for the same solution.

TL;DR:

Prepare the Tomcat server and engine-rest configuration as Config Maps. The important part in conf/server.xml :

<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml"
  testOnBorrow="true" validationQuery="SELECT 1" validationInterval="30000" />
kubectl create configmap camunda-conf --from-file=conf/server.xml

Then mount:

          volumeMounts:
            - name: conf
              subPath: server.xml
              mountPath: /camunda/conf/server.xml
...
      volumes:
        - name: conf
          configMap:
            name: camunda-conf