Unable to use variable passed at runtime

Hello,

I am trying to use variables in XML passed during the creation of the process instance but it is throwing an error at runtime.

below is the code I am trying to use.

JAVA code:

Map<String,Object> variable = new HashMap<String, Object>();
variable.put(“owner”, requestDetails.getOwner());
variable.put(“assignee”,requestDetails.getAssignee());
String processId=runtimeService.startProcessInstanceByKey(requestDetails.getBpmnFileName(),variable).getId();

XML code:


<startEvent id="start" name="Start" flowable:initiator="${owner}" flowable:formFieldValidation="true"></startEvent>

even i tried flowable:initiator=${variable.owner}

The error which I am getting

{

"timestamp": "2021-06-07T10:16:13.024+00:00",

"status": 500,

"error": "Internal Server Error",

"trace": "org.flowable.common.engine.api.FlowableException: Error while evaluating expression: ${owner}\r\n\tat org.flowable.common.engine.impl.el.JuelExpression.setValue(JuelExpression.java:77)\r\n\tat org.flowable.variable.service.impl.persistence.entity.VariableScopeImpl.setVariable(VariableScopeImpl.java:657)\r\n\tat org.flowable.engine.impl.persistence.entity.ExecutionEntityManagerImpl.createProcessInstanceExecution(ExecutionEntityManagerImpl.java:293)\r\n\tat org.flowable.engine.impl.util.ProcessInstanceHelper.createAndStartProcessInstanceWithInitialFlowElement(ProcessInstanceHelper.java:197)\r\n\tat org.flowable.engine.impl.util.ProcessInstanceHelper.createProcessInstance(ProcessInstanceHelper.java:106)\r\n\tat org.flowable.engine.impl.cmd.StartProcessInstanceCmd.startProcessInstance(StartProcessInstanceCmd.java:237)\r\n\tat org.flowable.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:126)\r\n\tat org.flowable.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:53)\r\n\tat org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:59)\r\n\tat org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:107)\r\n\tat org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:81)\r\n\tat org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:64)\r\n\tat org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:26)\r\n\tat org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)\r\n\tat org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:83)\r\n\tat org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:52)\r\n\tat org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)\r\n\tat org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)\r\n\tat org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)\r\n\tat org.flowable.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:121)\r\n\tat com.microservice.flowable.service.FlowableService.createProcessInstance(FlowableService.java:58)\r\n\tat com.microservice.flowable.service.FlowableService$$FastClassBySpringCGLIB$$9cb64d7e.invoke(<generated>)\r\n\tat org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\r\n\tat org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)\r\n\tat org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)\r\n\tat org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)\r\n\tat org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)\r\n\tat org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\r\n\tat org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)\r\n\tat org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)\r\n\tat com.microservice.flowable.service.FlowableService$$EnhancerBySpringCGLIB$$ee3fff99.createProcessInstance(<generated>)\r\n\tat com.microservice.flowable.controller.FlowableController.createInstance(FlowableController.java:55)\r\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:564)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)\r\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1063)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:652)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:733)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)\r\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)\r\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)\r\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\r\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)\r\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\r\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)\r\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)\r\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n\tat java.base/java.lang.Thread.run(Thread.java:832)\r\nCaused by: org.flowable.common.engine.impl.javax.el.PropertyNotWritableException: Cannot write property: owner\r\n\tat org.flowable.common.engine.impl.javax.el.CouldNotResolvePropertyELResolver.setValue(CouldNotResolvePropertyELResolver.java:55)\r\n\tat org.flowable.common.engine.impl.javax.el.CompositeELResolver.setValue(CompositeELResolver.java:332)\r\n\tat org.flowable.common.engine.impl.de.odysseus.el.tree.impl.ast.AstIdentifier.setValue(AstIdentifier.java:117)\r\n\tat org.flowable.common.engine.impl.de.odysseus.el.tree.impl.ast.AstEval.setValue(AstEval.java:95)\r\n\tat org.flowable.common.engine.impl.de.odysseus.el.TreeValueExpression.setValue(TreeValueExpression.java:146)\r\n\tat org.flowable.engine.impl.delegate.invocation.ExpressionSetInvocation.invoke(ExpressionSetInvocation.java:37)\r\n\tat org.flowable.engine.impl.delegate.invocation.DelegateInvocation.proceed(DelegateInvocation.java:32)\r\n\tat org.flowable.engine.impl.delegate.invocation.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:26)\r\n\tat org.flowable.engine.impl.el.JuelExpression.resolveSetValueExpression(JuelExpression.java:51)\r\n\tat org.flowable.common.engine.impl.el.JuelExpression.setValue(JuelExpression.java:75)\r\n\t... 83 more\r\n",

"message": "Error while evaluating expression: ${owner}",

"path": "/createProcess"

}Preformatted text

That should work. What’s the type of requestDetails.getOwner()? Have you tried with a normal string?
The exception doesn’t seem to contain all details (i.e. the missing property). Can you add more details about what you’re doing (it looks like a custom REST endpoint?)