NullPointerException while creating process instance

Hi All,

We are using flowable(6.7.2) embedded in a Spring Boot app. We are getting “NullPointerException” while creating a process instance when we pass large number of assignees for a user task. It works fine when the assignees count is less. Refer the error message and code snippet below

Error Message
Error while closing command context
java.lang.NullPointerException: Cannot invoke “org.flowable.common.engine.impl.persistence.entity.data.DataManager.create()” because the return value of “org.flowable.common.engine.impl.persistence.entity.AbstractEntityManager.getDataManager()” is null
at org.flowable.common.engine.impl.persistence.entity.AbstractEntityManager.create(AbstractEntityManager.java:47)
at org.flowable.common.engine.impl.persistence.entity.ByteArrayRef.setBytes(ByteArrayRef.java:102)
at org.flowable.common.engine.impl.persistence.entity.ByteArrayRef.setValue(ByteArrayRef.java:80)
at org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntityImpl.setBytes(VariableInstanceEntityImpl.java:115)
at org.flowable.variable.service.impl.types.JsonType.setValue(JsonType.java:124)
at org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntityImpl.setValue(VariableInstanceEntityImpl.java:141)
at org.flowable.variable.service.impl.persistence.entity.VariableScopeImpl.createVariableInstance(VariableScopeImpl.java:906)
at org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.createVariableInstance(ExecutionEntityImpl.java:839)
at org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.createVariableLocal(ExecutionEntityImpl.java:865)
at org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.setVariable(ExecutionEntityImpl.java:739)
at org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.setVariable(ExecutionEntityImpl.java:702)
at org.flowable.variable.service.impl.persistence.entity.VariableScopeImpl.setVariable(VariableScopeImpl.java:659)
at org.flowable.engine.impl.util.ProcessInstanceHelper.createAndStartProcessInstanceWithInitialFlowElement(ProcessInstanceHelper.java:227)
at org.flowable.engine.impl.util.ProcessInstanceHelper.createProcessInstance(ProcessInstanceHelper.java:109)
at org.flowable.engine.impl.cmd.StartProcessInstanceCmd.startProcessInstance(StartProcessInstanceCmd.java:239)
at org.flowable.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:128)
at org.flowable.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:53)
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.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.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:162)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

We are using the below code snippet to create a process instance,
ProcessInstance processInstance = processEngine.getRuntimeService()
** .startProcessInstanceById(processDefinitionId, inputVars);**
where inputvars will contain the list of assignees as json.

Kindly let us know if there are any restriction to assignees count for a user task or any restriction on size of the process variables(inputVars)

Thanks,
Sriram

Hi @sriramb

According to the stacktrace you are using the wrong method:

public ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey) {
      return commandExecutor.execute(new StartProcessInstanceCmd<ProcessInstance>(null, processDefinitionId, businessKey, null));
}

The seconds parameter is the businssKey of the process not a process variable.

You have to pass a Map<String, Object> which is considered as process variables:

public ProcessInstance startProcessInstanceById(String processDefinitionId, Map<String, Object> variables) {
     return commandExecutor.execute(new StartProcessInstanceCmd<ProcessInstance>(null, processDefinitionId, null, variables));
}

I hope this helps you.

Regards,
Simon

Hi @amporsim

Thanks for your response. My bad, the type of inputVars is Map<String,Object> only. And i am using the below definition

Regards,
Sriram

Ok and how does the inputVars look like? What kind of values do you have in the map?

Please refer the inputVars map values,

The yellow highlighted variables are the keys in the inputVars map. And the green highlighted is the assignees list.

We have written a listener for user task where the users will be assigned to the user task. refer the listener code and “addCandidateUsers” method implementation from TaskEntityImpl class below,

I hope this info will give you better understanding @amporsim. Kindly let me know if there is any issue in the input parameters to processEngine.getRuntimeService() .startProcessInstanceById(processDefinitionId, inputVars) method.

Thanks

Hi All,

One more query, when we set a variable using execution.setVariable(variableName, value) , is there any limitation on text size for the value ?

No, there isn’t. If the value is too large for the column (2000 or 4000 chars, depending on your database), the engine will switch to using bytes. Which is what is happening here.

The exception is very strange, the internal dataManager is null … which can normally never happen. Did you customize the persistence layer? Do you have a way we could reproduce this?

Hi @joram

Thanks for the info. Actually in my case, i am trying to set a text value which consist of around 5k characters. While executing this execution.setVariable(), i am getting the above error…

For reproducing this error, pls try setting a text value which has around 5k chars. You may get this error…

Reg persistence layer… it would be helpful, if you mention the respective / important files in persistence layer so that it would be easier to check and revert

I’ve done a local test here, with 25K characters and things work fine. A unit test would help a lot here.

In Flowable these interfaces are called either EntityManager or DataManager

Hi @joram ,

I have checked and i couldn’t figure out the exact Data Manager responsible for this setVariable action. If you remember, can you pin point the Data Manager which is responsible for this action.

I could see many data managers, specific name will be helpful.

Also, i could see this configuration of max length of a string, will this be anyway responsible for the above issue ?

Thank you !

Hi @joram ,

The persistence layer you are mentioning is org.flowable.common.engine.impl.persistence

If it is this, then we haven’t customized any persistence layer.

It would be helpful if we know when this internal dataManager can become null.

Thanks !

Hi @joram , After adding the below configuration, it seems to be supporting more than 4k chars,

image

Thanks for your responses !

Hey @sriramb,

You never mentioned that you are using the MongoDB integration. Have a look at Jobs are not getting executed - #13 by filiphr. Our MongoDB integration is in alpha state and it isn’t recommended for production usage.

Cheers,
Filip