Everything seems OK. I can:
i) start a process with an assignee
ii) get a list of tasks for an assignee
BUT then I face the below issue when I try to complete a task:
{
"timestamp": "2018-08-24T10:26:02.438+0000",
"status": 500,
"error": "Internal Server Error",
"message": "\n### Error querying database. Cause: org.flowable.common.engine.api.FlowableException: unknown variable type name jpa-entity\n### The error may exist in org/flowable/variable/service/db/mapping/entity/VariableInstance.xml\n### The error may involve org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntityImpl.selectVariablesByExecutionId\n### The error occurred while handling results\n### SQL: select * from ACT_RU_VARIABLE where EXECUTION_ID_ = ? and TASK_ID_ is null\n### Cause: org.flowable.common.engine.api.FlowableException: unknown variable type name jpa-entity",
"path": "/tasks/f6f90ad6-a787-11e8-b0aa-f85971c49eb0"
}
Could you please look into this issue?
To re-produce this issue, please refer to sample project flowable-jpa-demo
I’ve checked src code.
It runs FlowableJpaAutoConfiguration class which sets entityManagerFactory so jpa-entity type should be registered. It looks like IbatisVariableTypeHandler contains different variableTypes mapping.
It looks like a bug.
To be honest I don’t catch it why it works this way. I mean why it uses IbatisVariableTypeHandler created in AppEngineConfiguration instead of ProcessEngineConfiguration.
Maybe someone knows how it works under the hood ?
I’ve checked source code and I see that AppEngineCongiration and ProcessEngineCnfiguration share sqlSessionFactory (see AppEngineConfiguration.configuratorsAfterInit)
But it looks like a feature not a bug
Check this code:
It initializes sessionFactory and then invokes:
configuratorsAfterInit() which copies sqlSessionFactory from AppEngineCongiration to SpringProcessEngineConfiguration so it’s the reason why IbatisVariableTypeHandler doesn’t see jpa-entity type.
Thanks for the feedback and analysis.
For your purpose, you could also use the flowable-spring-boot-starter-process-rest module instead of the one you are using now. Then it will work. But we do need a way to make this work with the app engine included as well of course.
For information, I have the same (?) problem on Flowable Admin UI 6.3.1 when listing instance variables on a process instance that contains a jpa entity (clicking on “Variables” from http://localhost:8080/flowable-admin/#/process-instance/myPid):
Error querying database. Cause: org.flowable.common.engine.api.FlowableException: unknown variable type name jpa-entity
The error may exist in org/flowable/variable/service/db/mapping/entity/HistoricVariableInstance.xml
The error may involve org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntityImpl.selectHistoricVariableInstanceByQueryCriteria
The error occurred while handling results
SQL: select * from ( select a., ROWNUM rnum from ( select RES. from ACT_HI_VARINST RES WHERE RES.PROC_INST_ID_ = ? order by NAME_ asc ) a where ROWNUM < ?) where rnum >= ?
Cause: org.flowable.common.engine.api.FlowableException: unknown variable type name jpa-entity
at org.flowable.ui.admin.service.engine.FlowableClientService.executeRequest(FlowableClientService.java:150) ~[flowable-ui-admin-logic-6.3.1.jar:6.3.1]
at org.flowable.ui.admin.service.engine.FlowableClientService.executeRequest(FlowableClientService.java:118) ~[flowable-ui-admin-logic-6.3.1.jar:6.3.1]
at org.flowable.ui.admin.service.engine.FlowableClientService.executeRequest(FlowableClientService.java:114) ~[flowable-ui-admin-logic-6.3.1.jar:6.3.1]
at org.flowable.ui.admin.service.engine.ProcessInstanceService.getVariables(ProcessInstanceService.java:142) ~[flowable-ui-admin-logic-6.3.1.jar:6.3.1]
at org.flowable.ui.admin.rest.client.ProcessInstanceClientResource.getVariables(ProcessInstanceClientResource.java:74)
I tried adding the SpringAppEngineConfigurer like proposed above, but until now I wasn’t able to make it work. I also added the 2 other types “HistoricJPAEntityVariableType” and “HistoricJPAEntityListVariableType”.
Any tip on how to do this would be welcome…
Thanks for your reply. Very good to know that AppEngineConfiguration and ProcessEngineConfiguration share sqlSessionFactory!
Back to the issue, I am not so sure if it is a bug, hence I did not open a github issue for this. Not agreeable it is a feature either
Thanks @rgorzkowski for the workaround. This is something similar that I have tried out and it works.
To fix the issue, basically I have created an extension to help create new jpa-entity via setValue method. That is actually a custom jpa variable type and very similar to but not extended the JPAEntityVariableType. Then register it:
> public class ProcessEngineConfigurer implements EngineConfigurationConfigurer {
@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
List<VariableType> customVariableTypes = new ArrayList<>();
customVariableTypes.add(new JPAEntityVariableType());
engineConfiguration.setCustomPreVariableTypes(customVariableTypes);
}
I wonder if it is a right way to do as I am having kind of 2 jpa variable types inside the engine.
Do you need SpringAppEngineConfiguration in your project ?
If not you can also exclude SpringAppEngineConfiguration by changing dependency, as @tijs said .
Thanks @rgorzkowski for looking into this. To provide some more clarity. When multiple engines are running then one of the engine takes the “lead” and is responsible for initializing the database, configuring the session factory etc. When the app engine is present that this engine is the lead.
This means that the VariableTypes which are used will not be the one from the process engine configuration, but the ones from the AppEngine. I think that something needs to be done in the ProcessEngineConfigurator.
@rgorzkowski I think that if one creates a copy of the flowable-spring-boot-sample-jpa and use the flowable-spring-boot-starter that it should be enough for reproducing this problem (as you already noticed)
Regarding your previous post.
Frankly speaking I don’t know how is it possible that it works.
If you set customPreVariables on ProcessEngineConfiguration and AppEngineConfiguration exists on classpath, the App engine is the lead as @filiphr said so this code from ProcessEngineConfiguration won’t be invoked:
@Override
public void initMybatisTypeHandlers(Configuration configuration) {
configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler(variableTypes));
}
But I might be wrong. Do you have any example project on github ?
Now, could you please advise if there is any concern with the approach (2 jpa variable types initialized) in my previous post?
Concerning the probably related flowable ui admin problem: I pushed my code to https://github.com/soframel/flowable-spring-testjpa
It is only used to create a process instance with a JPA entity as a variable named “entity” (launch the class org.soframel.tests.flowable.spring.StartProcess).
But the code works fine: the problem is that later if you configure flowable-admin to use the same DB (in ~/flowable-db/db), and you browse to the process instance variable list, you get the exception “unknown variable type name jpa-entity”.
Hello,
I’m starter with flowable, i got the same error
Event that i add the dependency “flowable-spring-boot-starter-process-rest”
but also i got the same error please can any one help me with easy steps
Thanks in advance