AnsweredAssumed Answered

User/membership creation programmatically fails in 5.11

Question asked by oops on Dec 24, 2012
Latest reply on Dec 26, 2012 by jbarrez
Hi guys,

I faced a problem in 5.11, it was OK with Activiti 5.10.

I am creating user and membership programmatically - and it fails with "Referential integrity constraint violation"

The code is simple:

        String username = "someName";
        User user = identityService.newUser(username);

        identityService.createMembership(username, "admin"); // other groups also tried..

The default users/memberships ("kermit", etc) are created successfully.

What I noticed (I am not sure that it definitely the reason of the problem, but providing it just in case).
1. In a case of initial ("kermit" etc) users/memberships creation: CommandContextInterceptor.execute() flag contextReused stays false (due to context == null at that stage).
2. In a case of my users/memberships creation - this flag is true (due to not null context).
javadoc for ProcessEngineConfiguration says "One transaction per service method." Just in case we tried ProcessEngineConfiguration.setTransactionsExternallyManaged(false); This did not help also.

So, I am asking for some directives from you..
Thanks in advance.