cancel
Showing results for 
Search instead for 
Did you mean: 

IdentityService.saveUser requires more than declared User

tstephen
Champ on-the-rise
Champ on-the-rise
The IdentityService declares

  void saveUser(User user)
but when I extended one of my existing classes to provide the expected User interface and passed it in I received the ClassCastException below. I realise that creating a User object with IdentityService.newUser is the expected usage but it would be nice to avoid copying the data from my user object to the Activiti user object. At least if this is necessary it would be good to declare a public class that must be passed into the saveUser method. 

I am using Activiti 5.3. The attached classes can drop into the 5.3 activiti-engine-examples to illustrate the problem.

Tim

java.lang.ClassCastException: org.activiti.examples.bpmn.servicetask.UserInfo cannot be cast to org.activiti.engine.impl.identity.UserEntity
   at org.activiti.engine.impl.cmd.SaveUserCmd.<init>(SaveUserCmd.java:30)
   at org.activiti.engine.impl.IdentityServiceImpl.saveUser(IdentityServiceImpl.java:54)
   at org.activiti.examples.bpmn.servicetask.IdentityTask.execute(IdentityTask.java:21)
   at org.activiti.examples.bpmn.servicetask.IdentityTaskTest.testCreateUser(IdentityTaskTest.java:19)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at junit.framework.TestCase.runTest(TestCase.java:168)
   at junit.framework.TestCase.runBare(TestCase.java:134)
   at junit.framework.TestResult$1.protect(TestResult.java:110)
   at junit.framework.TestResult.runProtected(TestResult.java:128)
   at junit.framework.TestResult.run(TestResult.java:113)
   at junit.framework.TestCase.run(TestCase.java:124)
   at junit.framework.TestSuite.runTest(TestSuite.java:232)
   at junit.framework.TestSuite.run(TestSuite.java:227)
   at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
That will not work - Activiti needs to know how to persist your user. One way would be to extend the UserEntity.

frederikherema1
Star Contributor
Star Contributor
If you want to use your own objects, implementing the User interface, you should also override the identitySession. Search the forum for "identitysession" and "ldap" and you'll find plenty of posts about this topic.

tstephen
Champ on-the-rise
Champ on-the-rise
Ok, I was suggesting that the param should be UserEntity but now I see that alternate identitySession could use the simpler User object it makes sense. And thanks for the tip the LDAP identitySession looks interesting.