Using StandardEditor as Process Form: IllegalArgumentException: entity is null

I’m using a StandardEditor for my process and everything is working fine, I can run the full process without any issue or any error.
The issue though is, when I try to start the process from the BProc menu:
BProc -> Start Process
Then select the very same process and click the “Start Process” button I get an the error: Entity is null:
Here is the error stack:

java.lang.IllegalArgumentException: entity is null
	at com.haulmont.bali.util.Preconditions.checkNotNullArgument(
	at com.haulmont.cuba.gui.screen.StandardEditor.setupEntityToEdit(
	at com.haulmont.cuba.gui.screen.StandardEditor.beforeShow(
	at com.haulmont.cuba.gui.screen.Screen.fireEvent(
	at com.haulmont.cuba.gui.screen.UiControllerUtils.fireEvent(
	at com.haulmont.addon.bproc.web.screens.startprocess.StartProcessScreen.onProcessDefinitionsTableStartProcessActionPerformed(
	at com.haulmont.cuba.gui.components.actions.BaseAction.actionPerform(
	at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(
	at com.haulmont.cuba.web.widgets.CubaButton.fireClick(
	at com.vaadin.ui.Button$
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.base/java.lang.reflect.Method.invoke(
	at com.vaadin.server.ServerRpcManager.applyInvocation(
	at com.vaadin.server.ServerRpcManager.applyInvocation(
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(
	at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(
	at com.vaadin.server.communication.ServerRpcHandler.handleRpc(
	at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(
	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(
	at com.vaadin.server.VaadinService.handleRequest(
	at com.vaadin.server.VaadinServlet.service(
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(
	at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(
	at org.springframework.web.filter.CompositeFilter.doFilter(
	at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.service(
	at org.apache.coyote.AbstractProcessorLight.process(
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.base/java.util.concurrent.ThreadPoolExecutor$
	at org.apache.tomcat.util.threads.TaskThread$
	at java.base/

You mean that you defined the StandardEditor screen as a start process form in the modeler, right? If so, the did you look at this section in the documentation?

Yes , of course I did. I can start the process and with the here mentioned and assumed " Start process button", which is called differently in my code but of course working fine. As I said I can run the process perfectly fine starting it from the Entity Browser screen.

    public void onSubmitBtnClick() {
        TravelRequest travelRequest = getEditedEntity();
        Map<String, Object> processVariables = new HashMap<>();
        processVariables.put("travelRequest", travelRequest);
        commitChanges().then(() -> {
            bprocRuntimeService.startProcessInstanceByKey( "travelrequest", travelRequest.getStartDate() + ": " + travelRequest.getProjectNumber(), processVariables);
            System.out.println("Process Started?");
        }).then(() -> {

I am assuming though, that I also need to override the button that starts the process from the BProc menu, basically that should just open the StandardEditor Form for my Travelrequest, where the user then finds the Submit button which starts the process.

1 Like

In general case, the StandardEditor that is used for editing an entity cannot be used as a start process form. You may have one screen for editing the entity (you can have a “Start process” button inside the editor, of course), and to have a second screen, that is also an entity editor, but it is configured to be a start process form and it, for example, can display a limited number of entity fields - only those that are required for process start.
You can find an example of such a second screen in the bproc-sampler project. See the there. Look at the code

    protected void onInit(InitEvent event) {
        Order order = metadata.create(Order.class);

It creates a new entity instance and set is an edited entity to the editor. That is probably what the standard editor doesn’t do.

Thanks Max,
whereas your explanation about having to create a second form for the start process isn’t correct, your code snippet helped me solve the issue.
I am using ONE StandardEditor form for everything, Creating the entity as well as for process handling: start process and task completions. My onInit() method now looks as follows, and the problem is hereby solved:

    protected TravelRequest travelRequest;


    protected void onInit(InitEvent event){
        if (travelRequest != null) {
        } else {
            TravelRequest travelRequest = metadata.create( TravelRequest.class );