cancel
Showing results for 
Search instead for 
Did you mean: 

Referential integrity constraint violation

fbrcls
Champ in-the-making
Champ in-the-making
Hi,

I receive the following exception during my process execution:

### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_VAR_BYTEARRAY: PUBLIC.ACT_RU_VARIABLE FOREIGN KEY(BYTEARRAY_ID_) REFERENCES PUBLIC.ACT_GE_BYTEARRAY(ID_) ('20')"; SQL statement:

In attachment the process definition.

The process execution is the following: first we come in the service task "findTaxFile" that assigns "null" to the process variable "taxFile". After that we come in another service task "createTaxFile" that assigns a not null value to the same process variable "taxFile". All these task are synchronous. And finally we come to a manual asynchronous task "communicateTurnoverRequest". The error happens when activiti tries to commit the transaction before the manual task.

When I define the "createTaxFile" as asynchronous, the error doesn't happen anymore.

Is this a bug in Activiti of a misuse of the engine?

Thanks for your help. 
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
I'm not quite sure, but I think it is due to first adding null as value there and then replacing it. Is there any reason why you set null? Isn't the fact that the variable doesn't exist is enough?

fbrcls
Champ in-the-making
Champ in-the-making
The service task calls a Java bean that can return null as value. That's the reason. Later in the process I will check on this value.

jbarrez
Star Contributor
Star Contributor
I got the use case, im just saying is that it is probably because the engine doesn't know the type when you pass in null. Try to not set the variable when your receive it, and use execution.getVariable() == null later on .

johnm
Champ in-the-making
Champ in-the-making
Hi,
just adding my own experience, in case it helps some one (using activiti version 5.14). We had the same issue, but with a slightly different (but related) cause.

We have a process variable, that contains the stringified value of a java enum.  In one of my integration tests the variable was accidentally (incorrectly) initialised to "" (empty string).

With this initialisation in place, eventually (some time later) the test would fail with the above violation. I think it relates somehow to it being a different java type on either occasion that activiti serializes it.

I believe it is essentially the same issues as described in https://activiti.atlassian.net/browse/ACT-1839.

One I removed the (incorrect) initialisation.. the problem went away.

hth's
John