Hi, I am pretty new to Camunda and working on a user/group/membership-sync between the Celum DAM and Camunda, which we will need for our workflows, but I ran into some problems.
Setup
I installed Camunda 7.9. locally, the tomcat version with the default h2 database. Everything worked as expected so far.
Problems
When I tried to create a user or a group I’ve always received the following error:
org.camunda.bpm.engine.ProcessEngineException: ENGINE-03002 Cannot add TRANSIENT entity with id 'celum_488' and type 'class org.camunda.bpm.engine.impl.persistence.entity.UserEntity' into cache. An entity with the same id and type is already in state 'TRANSIENT'
So I implemented the following workaround (marked by comment):
User user = identityService.createUserQuery()
.userId(id).singleResult();
if (user == null) {
user = identityService.newUser(id);
dbEntityManager.getDbEntityCache().remove((UserEntity) user); // here
identityService.saveUser(user);
}
if (!firstName.equals(user.getFirstName()) || !lastName.equals(user.getLastName()) || !email.equals(user.getEmail())) {
user.setFirstName(firstName);
user.setLastName(lastName);
user.setEmail(email);
dbEntityManager.getDbEntityCache().remove((UserEntity) user); // here
identityService.saveUser(user);
}
Like that I got rid of the error, but it still didn’t work. I always got a unique index or primary key violation. I noticed that the statements are executed as a batch, but that shouldn’t be a problem. I also checked the constraint that is supposed to be violated, but this seems to be impossible, because user and group ids are unique. Here is an excerpt of the log:
org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "ACT_UNIQ_AUTH_GROUP_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, GROUP_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, 'celum_489', 2, 'celum_489', 45)"; SQL statement:
insert into ACT_RU_AUTHORIZATION (ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_)
values (?, ?, ?, ?, ?,?, ?, 1) [23505-190]
'. Flush summary:
[
INSERT HistoricJobLogEventEntity[87877f40-4f30-11ea-8ee4-005056c00001]
INSERT AuthorizationEntity[87752fb0-4f30-11ea-8ee4-005056c00001]
...
INSERT HistoricActivityInstanceEventEntity[End_CelumUserGroupSync:8787311f-4f30-11ea-8ee4-005056c00001]
...
INSERT UserEntity[celum_487]
...
INSERT GroupEntity[celum_489]
...
INSERT MembershipEntity[877fb706-4f30-11ea-8ee4-005056c00001]
...
DELETE MessageEntity[87467e8d-4f30-11ea-8ee4-005056c00001]
DELETE ExecutionEntity[87467e8b-4f30-11ea-8ee4-005056c00001]
UPDATE HistoricProcessInstanceEventEntity[87467e8b-4f30-11ea-8ee4-005056c00001]
DELETE_BULK deleteAuthorizationsForResourceId {resourceId=87467e8b-4f30-11ea-8ee4-005056c00001, resourceType=8}
]
I am glad for any help I can get. I looked at the official example to populate Camunda with some users and groups and it is doing exactly the same as I did.