cancel
Showing results for 
Search instead for 
Did you mean: 

Passing JPA process variable to callactivity

hheckel
Champ in-the-making
Champ in-the-making
Hello all,

can anybody point me in the right direction, if and how JPA process variables can be passed to a call activity?

Thanks and best regards,
Holger.
8 REPLIES 8

p4w3l
Champ in-the-making
Champ in-the-making
Just define "Input parameters" in "Main config" of your callactivity object by filling 'Source' and 'Target' where source is process variable name ( can be of type JPA or not ) and target is desired variable name in called process.

hheckel
Champ in-the-making
Champ in-the-making
Thanks for the quick response.

That's exactly what I tried, but I receive the following error message:



Mar 7, 2013 12:58:25 AM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: Couldn't serialize value 'org.apache.openjpa.enhance.com$mycompany$myapp$jpa$model$MyJPAClass$pcsubclass@6ebe8853' in variable 'jpaParameter'
at org.activiti.engine.impl.variable.SerializableType.serialize(SerializableType.java:98)
at org.activiti.engine.impl.variable.SerializableType.setValue(SerializableType.java:73)

Caused by: java.io.NotSerializableException: org.apache.openjpa.enhance.RedefinitionHelper$1

p4w3l
Champ in-the-making
Champ in-the-making
For me it works on EclipseLink. My JPA objects don't implement Serialisable but maybe yours in OpenJPA they should?

frederikherema1
Star Contributor
Star Contributor
Since activiti is using the "SerializableType" instead of the "JPAEntityType", there is something wrong:

  • Is activiti configured to use JPA (entityManagerFactory set on process-engine configuration)

  • Is the entity's ID annotated using @ID? see user guide for the requirements to use JPAVariables out of the box

hheckel
Champ in-the-making
Champ in-the-making
- Yes, activiti has been configured to use JPA
- Yes, the entity's ID has been annotated using @Id

The process variable is created and persisted prior to starting the process instance. The act_ru_variable table shows the variable as 'jpa-entity', it refers to the correct java class and it's data fields are accessible to the engine (gateways in the process definition are executed correctly based on the entity's values).
The problem occurs, when I am trying to pass the variable as a parameter to the call activity as described above.

Any ideas? Thanks!

hheckel
Champ in-the-making
Champ in-the-making
Update:

I followed the example configuration in the book 'Activiti in Action' (a "must read", btw…)

Works like a charm now.

Thanks for everybody's input!

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
What was the issue? Can you elaborate, so it might help others?

hheckel
Champ in-the-making
Champ in-the-making
Can't really tell what the problem was, but I did follow the documentation in the book, which seems to go a little more into details compared to the user guide.