jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
694 stars 124 forks source link

EntityDataTask (Create and Modify) should join the current transaction #2454

Closed gorbunkov closed 12 months ago

gorbunkov commented 1 year ago

Jmix version: 1.5.4

Currently, in the BpmCreateEntityActivityBehavior and in the BpmModifyEntityActivityBehavior the joinTransaction flag of SaveContext is explicitly save to false:

SaveContext saveContext = new SaveContext().saving(entity).setJoinTransaction(false);
dataManager.save(saveContext);

It looks that joinTransaction must be true here.

joinTransaction equal to false leads to the following error: when the EntityDataTask follows the service task that creates some entity, then an attempt to modify just created entity in the EntityDataTask leads to a deadlock. This may be reproduced on the project:

bpm-quad.zip test_for_jmix1.bpmn20.xml.zip

See also: https://github.com/jmix-framework/jmix/issues/2255

gorbunkov commented 1 year ago

For QA: please, do a quick smoke for EntityDataTask (create and modify)

rusiaikinat commented 1 year ago

image Task type: Modify entity Process variable: initiator Entity name: User

Deploy process

org.flowable.common.engine.api.FlowableException: Errors while parsing:
[Validation set: 'flowable-executable-process' | Problem: 'jmix-modify-entity-task-no-entity-attributes'] : No entityAttributes is defined on the modify entity activity - [Extra info : processDefinitionId = process | processDefinitionName = Process |  | id = Activity_1cyd823 | ] ( line: 15, column: 75)

    at org.flowable.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:177)
    at org.flowable.engine.impl.bpmn.deployer.ParsedDeploymentBuilder.createBpmnParseFromResource(ParsedDeploymentBuilder.java:97)
    at org.flowable.engine.impl.bpmn.deployer.ParsedDeploymentBuilder.build(ParsedDeploymentBuilder.java:55)
    at org.flowable.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:78)
    at org.flowable.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:62)
    at org.flowable.engine.impl.cmd.DeployCmd.executeDeploy(DeployCmd.java:135)
    at org.flowable.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:70)
    at org.flowable.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:45)
    at org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:67)
    at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:140)
    at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:114)
    at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:72)
    at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:26)
    at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
    at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:105)
    at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:57)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
    at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:57)
    at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
    at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
    at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
    at org.flowable.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:99)
    at org.flowable.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:206)
    at io.jmix.bpmui.screen.modeler.BpmnModelerScreen.lambda$deployProcess$7(BpmnModelerScreen.java:302)
    at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    at io.jmix.ui.action.BaseAction.actionPerform(BaseAction.java:220)
    at io.jmix.ui.sys.DialogsImpl$OptionDialogBuilderImpl.lambda$show$0(DialogsImpl.java:344)
    at io.jmix.ui.widget.JmixButton.fireClick(JmixButton.java:77)
    at com.vaadin.ui.Button$1.click(Button.java:57)
rusiaikinat commented 1 year ago

Task type: Modify entity Process variable: initiator Entity name: User Update Tast type: Create entity

java.lang.IllegalArgumentException: MetaClass not found for null
    at io.jmix.core.metamodel.model.impl.SessionImpl.getClass(SessionImpl.java:43)
    at io.jmix.core.impl.MetadataImpl.getClass(MetadataImpl.java:134)
    at io.jmix.bpmui.screen.modeler.properties.entitydatatask.EntityDataTaskPropertiesFragment.collectMandatoryEntityAttributes(EntityDataTaskPropertiesFragment.java:424)
    at io.jmix.bpmui.screen.modeler.properties.entitydatatask.EntityDataTaskPropertiesFragment.updateEntityAttributesFragment(EntityDataTaskPropertiesFragment.java:210)
    at io.jmix.bpmui.screen.modeler.properties.entitydatatask.EntityDataTaskPropertiesFragment.lambda$initEntityNameLookupField$9(EntityDataTaskPropertiesFragment.java:229)
    at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    at io.jmix.ui.component.impl.AbstractComponent.publish(AbstractComponent.java:85)
    at io.jmix.ui.component.impl.AbstractValueComponent.setValue(AbstractValueComponent.java:110)
    at io.jmix.bpmui.screen.modeler.properties.entitydatatask.EntityDataTaskPropertiesFragment.lambda$initProcessVariableLookupField$6(EntityDataTaskPropertiesFragment.java:186)
    at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    at io.jmix.ui.component.impl.AbstractComponent.publish(AbstractComponent.java:85)
    at io.jmix.ui.component.impl.AbstractValueComponent.setValue(AbstractValueComponent.java:110)
    at io.jmix.bpmui.screen.modeler.properties.entitydatatask.EntityDataTaskPropertiesFragment.onEntityDataTaskDcItemPropertyChange(EntityDataTaskPropertiesFragment.java:296)
    at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    at io.jmix.ui.model.impl.InstanceContainerImpl.itemPropertyChanged(InstanceContainerImpl.java:182)
    at io.jmix.core.entity.BaseEntityEntry.firePropertyChanged(BaseEntityEntry.java:198)
    at io.jmix.core.impl.EntityInternals.fireListeners(EntityInternals.java:90)
    at io.jmix.bpmui.model.EntityDataTaskModel.setTaskType(EntityDataTaskModel.java:91)
    at io.jmix.core.metamodel.model.utils.MethodsCache$SettersHolder.accept(MethodsCache.java:241)
    at io.jmix.core.entity.BaseEntityEntry.setAttributeValue(BaseEntityEntry.java:104)
    at io.jmix.core.entity.EntityValues.setValue(EntityValues.java:73)
    at io.jmix.core.entity.EntityValues.setValueEx(EntityValues.java:198)
    at io.jmix.core.entity.EntityValues.setValueEx(EntityValues.java:151)
    at io.jmix.ui.component.data.value.ContainerValueSource.setValue(ContainerValueSource.java:178)
    at io.jmix.ui.component.data.value.ValueBinder$ValueBindingImpl.setValueToSource(ValueBinder.java:316)
    at io.jmix.ui.component.data.value.ValueBinder$ValueBindingImpl.componentValueChanged(ValueBinder.java:309)
    at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
    at io.jmix.ui.component.impl.AbstractComponent.publish(AbstractComponent.java:85)
    at io.jmix.ui.component.impl.AbstractValueComponent.componentValueChanged(AbstractValueComponent.java:154)
    at io.jmix.ui.component.impl.AbstractField.lambda$attachValueChangeListener$ab1c93c8$1(AbstractField.java:145)
    at com.vaadin.ui.ComboBox.lambda$addValueChangeListener$bddd7469$1(ComboBox.java:837)
    at jdk.internal.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
gorbunkov commented 12 months ago

@rusiaikinat

  1. For the case of "Modify entity" - you haven't defined any field that must be updated. That caused the error. After you specify one or more attributes, everything should work fine.
  2. For the case with changing "Modify entity" type to "Create entity" - please create a separate issue. This problem is not related to the current issue.