AnsweredAssumed Answered

IdentityService.saveUser requires more than declared User

Question asked by tstephen on Mar 21, 2011
Latest reply on Mar 22, 2011 by tstephen
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)

Attachments

Outcomes