SBusinessDataNotFoundException: persistenceId of business data is null
Hi,
I have a problem with a new object I created in the BDM.
I created an object "Autorisation" and added 2 variables of this type in an existing object "MainModel".
In a form, I return a json array of Autorisation and in the task operation, I have a script to set the variable of the MainModel :
import com.company.model.Autorisation import java.util.logging.Logger Logger logger = Logger.getLogger("org.bonitasoft.TOREA") List autors = new ArrayList(); for( int i=0; i< contract_autorList.size(); i++ ){ Autorisation aa = new Autorisation(); Map aaIn = contract_autorList[i]; aa.name = (String) aaIn.get( "name" ); logger.info( "name : "+ aa.name ); aa.contact = (String) aaIn.get( "contact" ); logger.info( "contact : "+ aa.contact ); aa.email = (String) aaIn.get( "email" ); ; logger.info( "email : "+ aa.email ); autors.add( aa ); // if commented, there is no exception } return autors;
According to the log, I get the correct values but if the list I return is not empty, I get :
SBusinessDataNotFoundException: persistenceId of business data is null
What's happening and how could I fix this?
The complete exception is :
2020-05-25 09:22:53.907 -1000 AVERTISSEMENT: com.bonitasoft.engine.work.DefaultExceptionRetryabilityEvaluator THREAD_ID=286 | HOSTNAME=LAPTOP-KRQ98MIU | TENANT_ID=1 | Will NOT retry, nothing matching exception found: Exceptions: ↳org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException ↳org.bonitasoft.engine.core.operation.exception.SOperationExecutionException ↳org.bonitasoft.engine.business.data.SBusinessDataNotFoundException 2020-05-25 09:22:53.907 -1000 GRAVE: org.bonitasoft.engine.execution.work.InSessionBonitaWork THREAD_ID=286 | HOSTNAME=LAPTOP-KRQ98MIU | TENANT_ID=1 | The work [ExecuteFlowNodeWork: flowNodeInstanceId: 860129] failed. The failure will be handled. 2020-05-25 09:22:53.911 -1000 GRAVE: org.bonitasoft.engine.execution.work.InSessionBonitaWork THREAD_ID=286 | HOSTNAME=LAPTOP-KRQ98MIU | TENANT_ID=1 | org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException : "PROCESS_DEFINITION_ID=7081415389616795948 | PROCESS_NAME=liaison TE ATA 2 ou LLO fibre dédiée | PROCESS_VERSION=1.8 | PROCESS_INSTANCE_ID=41003 | ROOT_PROCESS_INSTANCE_ID=41003 | FLOW_NODE_DEFINITION_ID=6553067091763538825 | FLOW_NODE_INSTANCE_ID=860129 | FLOW_NODE_NAME=Montage projet Cablage | org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.business.data.SBusinessDataNotFoundException: persistenceId of business data is null" org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException: PROCESS_DEFINITION_ID=7081415389616795948 | PROCESS_NAME=liaison TE ATA 2 ou LLO fibre dédiée | PROCESS_VERSION=1.8 | PROCESS_INSTANCE_ID=41003 | ROOT_PROCESS_INSTANCE_ID=41003 | FLOW_NODE_DEFINITION_ID=6553067091763538825 | FLOW_NODE_INSTANCE_ID=860129 | FLOW_NODE_NAME=Montage projet Cablage | org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.business.data.SBusinessDataNotFoundException: persistenceId of business data is null at org.bonitasoft.engine.execution.StateBehaviors.executeOperations(StateBehaviors.java:565) at org.bonitasoft.engine.execution.state.ReadyActivityStateImpl.onEnterToOnFinish(ReadyActivityStateImpl.java:47) at org.bonitasoft.engine.execution.state.OnEnterAndFinishConnectorState.execute(OnEnterAndFinishConnectorState.java:67) at org.bonitasoft.engine.execution.state.OnEnterAndFinishConnectorState.execute(OnEnterAndFinishConnectorState.java:1) at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.executeState(FlowNodeExecutorImpl.java:133) at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.updateState(FlowNodeExecutorImpl.java:184) at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.stepForward(FlowNodeExecutorImpl.java:168) at org.bonitasoft.engine.execution.FlowNodeExecutorImpl.executeFlowNode(FlowNodeExecutorImpl.java:348) at org.bonitasoft.engine.execution.work.ExecuteFlowNodeWork.work(ExecuteFlowNodeWork.java:86) at org.bonitasoft.engine.execution.work.TxBonitaWork.lambda$0(TxBonitaWork.java:42) at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:274) at org.bonitasoft.engine.execution.work.TxBonitaWork.work(TxBonitaWork.java:42) at org.bonitasoft.engine.execution.work.LockProcessInstanceWork.work(LockProcessInstanceWork.java:63) at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:41) at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:41) at org.bonitasoft.engine.execution.work.failurewrapping.TxInHandleFailureWrappingWork.work(TxInHandleFailureWrappingWork.java:41) at org.bonitasoft.engine.execution.work.InSessionBonitaWork.work(InSessionBonitaWork.java:59) at org.bonitasoft.engine.work.BonitaThreadPoolExecutor.lambda$submit$1(BonitaThreadPoolExecutor.java:98) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.business.data.SBusinessDataNotFoundException: persistenceId of business data is null at org.bonitasoft.engine.operation.BusinessDataJavaMethodOperationExecutorStrategy.delegateBusinessValueForLeftOperand(BusinessDataJavaMethodOperationExecutorStrategy.java:68) at org.bonitasoft.engine.operation.BusinessDataJavaMethodOperationExecutorStrategy.computeNewValueForLeftOperand(BusinessDataJavaMethodOperationExecutorStrategy.java:46) at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.calculateRightOperandValue(OperationServiceImpl.java:124) at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.executeOperators(OperationServiceImpl.java:106) at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.execute(OperationServiceImpl.java:95) at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.execute(OperationServiceImpl.java:82) at org.bonitasoft.engine.execution.StateBehaviors.executeOperations(StateBehaviors.java:562) ... 20 more Caused by: org.bonitasoft.engine.business.data.SBusinessDataNotFoundException: persistenceId of business data is null at org.bonitasoft.engine.business.data.impl.BusinessDataServiceImpl.getPrimaryKeys(BusinessDataServiceImpl.java:180) at org.bonitasoft.engine.business.data.impl.BusinessDataServiceImpl.getPersistedValues(BusinessDataServiceImpl.java:192) at org.bonitasoft.engine.business.data.impl.BusinessDataServiceImpl.loadValueToSet(BusinessDataServiceImpl.java:168) at org.bonitasoft.engine.business.data.impl.BusinessDataServiceImpl.callJavaOperationOnEntity(BusinessDataServiceImpl.java:142) at org.bonitasoft.engine.business.data.impl.BusinessDataServiceImpl.callJavaOperation(BusinessDataServiceImpl.java:119) at org.bonitasoft.engine.operation.BusinessDataJavaMethodOperationExecutorStrategy.delegateBusinessValueForLeftOperand(BusinessDataJavaMethodOperationExecutorStrategy.java:62) ... 26 more
It looks like the authorizations reference in MainModel is in aggregation. It means that Authorization have their own lifecycle independently of MainModel. For this reason, an Authorization instance must already exists before attaching it to MainModel (it is not possible to create and attach an instance of an aggregation relation in the same transaction)
To achieve that you can in your use case create a process variable authorizations of type multiple Authorization and create all authorization instances in a previous operation. Then it will be possible to assign the authorizations variable to the MainModel reference in a second operation.
HTH
Romain
Comments
ok, I see the problem.
Thank you very much for the explanations!