org.h2.jdbc.JdbcBatchUpdateException: Value too long for column "TEXT_ VARCHAR(4000)"

On my Camunda API, when I execute:

runtimeService.startProcessInstanceByKey(existingWorkflowMetadata.id)

I get error:

Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity.insertHistoricVariableInstance (batch index #1) failed. Cause: org.h2.jdbc.JdbcBatchUpdateException: Value too long for column "TEXT_ VARCHAR(4000)": "'{""displayName"":""in_concept"",""selectedCatalogId"":{""label"":""APP (alpha)"",""value"":""802799426884""},""selectedDatabase"":{""... (46j6)"; SQL statement:...

I’ve read in multiple places I can store stuff as JSON, Java Objects and other formats such as BLOB to prevent this error from happening but I can’t seem to find where to go to apply this change.

Can someone please help me understand why this is happening and how to solve it?

I’m just getting started with Camunda API and BPMN. I can provide further logs and context as we go.

Hi @segura2794 ,

do you use camunda spin? If no, have a look at documentation here and here. With a properly configured environment using camunda spin, you should be able to simply store java objects in camunda and all serialization and deserialization will be handled by camunda internally.

Even with camunda spin this error can occur but only if you have a simple java string (no json string) like “abc…” excluding the outer quotes. Then you would need to either manually set the type for the camunda value using the TypedValue-API or convert it to a byte-array manually (this would make it necessary to reconvert it to a string on reading back the value).

Hope it helps!
Adagatiya

Hi Adagatiya,

Thank you for your response. We’re using Gradle, not Maven. Is this a problem if I were to use Camunda Spin?

Here’s how the dependencies on build.gradle look like:

    classpath brazilGradle.tool('KotlinGradlePlugin')
    classpath brazilGradle.tool('KotlinTrailsGradle')
    classpath brazilGradle.tool('KtlintGradle')

There are other dependencies that I didn’t include cause they are internal/proprietary dependencies.

I’ve a few questions that maybe you can answer, thank you again:

  1. Where does one usually configure the environment?

  2. Do you recognize this runtimeService.startProcessInstanceByKey(existingWorkflowMetadata.id) method? I think this is where the error is occurring.

  3. Is Camunda Spin completely necessary or can I do something to avoid this?

  4. I do see a plugins.processengine folder with a with a Kotlin file for some authorization plugin.

  5. You said:

What if I store it as a JSON String.

  1. Where can I see the file / place where I’m storing the values (that are causing the error)?

I’m so sorry, the only engineer that knows about this package is out sick, apologies if I’m asking basic stuff.

Thanks,
Daniel.

Hi @segura2794 ,

I hope I’m able to you help you on this.

We’re using Gradle, not Maven. Is this a problem if I were to use Camunda Spin?

I’m not that experienced with Gradle. I assume you have declared camunda as dependency using the maven central repository. Is That correct?

repositories {
	mavenCentral()
}

If that is correct, you could similarly declare the spin packages as dependencies in the same manner as you did with camunda itself.

Where does one usually configure the environment?

Besides having the dependencies there is only one little thing you have to make sure - if the spin process engine plugin is active or not. How that is achieved depends on how you configure your process engine. An example is given here: Configuring Spin Integration | docs.camunda.org

Do you recognize this runtimeService.startProcessInstanceByKey(existingWorkflowMetadata.id) method? I think this is where the error is occurring.

This methods starts a new process instance. The actual error occurs inside the process. Probably there is a script, execution listener or so being used inside your process definition that tries to set a string value that is larger than 4000 characters which then fails to persist.

Is Camunda Spin completely necessary or can I do something to avoid this?

Straightforward, after identifying the location where you try to set the large string value, you could manually convert it to binary but this would require you to remember reconverting it any time you read it back again and I would strongly recommend you against this! Camunda Spin is the recommended way to persist java objects, xml or json.

Kind regards
Adagatiya