Render Form programmatically from Spring Boot app

Hello,

I created a sample app (from here https://paulhh.wordpress.com/category/flowable/) using flowable-modeler UI app. Then I exported it as a BAR file. The bar file contains 1 bpmn and 4 forms.

I’m trying to deploy and control programmatically this app from my Spring Boot app.

  1. I did deployment this way:

String barFilePath = “C:\Users\Software3\Downloads\Gig App.bar”;
ZipInputStream inputStream = new ZipInputStream(new FileInputStream(barFilePath));
AppDeployment appDeployment = appRepositoryService.createDeployment()
.name(“Gig App”)
.addZipInputStream(inputStream)
.deploy();

It seems it is deployed just fine, I can see in the log:

o.f.a.engine.impl.deployer.AppDeployer : Processing app resource gigapp.app
o.f.e.c.impl.deployer.BpmnDeployer : BpmnDeployer: processing resource gigplan.bpmn
o.f.engine.impl.bpmn.parser.BpmnParse : Following warnings encountered during process validation: [Validation set: ‘flowable-executable-process’ | Problem: ‘flowable-exclusive-gateway-seq-flow-without-conditions’] : Exclusive gateway has at least one outgoing sequence flow without a condition (which isn’t the default one) - [Extra info : processDefinitionId = gigplan | processDefinitionName = Plan a gig | | id = sid-1CFFE4C0-E0CE-4C4D-8F4A-D4ABD14CD3EF | | activityName = Over 2k | ] ( line: 16, column: 84)
o.f.form.engine.deployer.FormDeployer : FormDeployer: processing resource form-transportBooking.form
o.f.form.engine.deployer.FormDeployer : FormDeployer: processing resource form-getgigdetails.form
o.f.form.engine.deployer.FormDeployer : FormDeployer: processing resource form-gigregion.form
o.f.form.engine.deployer.FormDeployer : FormDeployer: processing resource form-stadiumbooking.form

  1. Then I start process instance like this:

String processDefinitionId = “gigplan”;
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionId);

no errors in the log

  1. Then I am trying to render start form:

Object renderedForm = formService.getRenderedStartForm(processInstance.getProcessDefinitionId());

I’m getting exception;

Caused by: org.flowable.common.engine.api.FlowableObjectNotFoundException: Form with formKey ‘gigregion’ does not exist

However the form seems to be deployed previously on step 1.

What am I missing?

Could it be that I’m doing something that is not supported? I can see that the same app works just fine within flowable-task UI app. However I need to incorporate forms and flow inside existing webapp codebase and I need to have precise control on how forms are rendered and incorporated in existing app. Please point me out that it might be impossible or problematic using the flowable.

Thanks in advance.

The method you’re calling is an outdated one that is their for backwards compatibility.
The UI applications use the newer FormEngine. This engine works similar the process engine: it has deployments, models, instances of forms, etc. You can see that in your stacktrace, it used the FormDeployer from the form engine. You’d need to boot up the form engine with the process engine, and then you can query the FormRepositoryService and the FormService using the models you’ve deployed.

Also to note: for the process engine, forms are nothing way than a way to get variables in and out. So you can simply set variables directly on tasks or process instances, it would be the same effect.

1 Like

Hello joram
can you give an example of usign FormEngine?
im executing this but there’s no forms found in my BAR file :frowning:

		    RepositoryService repositoryService = processEngine.getRepositoryService();
	    FormRepositoryService formRepositoryService =  formEngine.getFormRepositoryService();
	    File file = new File(path);


	    ZipInputStream inputStream = new ZipInputStream(new FileInputStream(path));
	    String idDeployParent = repositoryService.createDeployment()
	            .name(file.getName())
	            .addZipInputStream(inputStream)
	            .deploy().getId();
	    
	    
	    DeploymentEntity deploymentEntity = (DeploymentEntity) repositoryService.createDeploymentQuery().list().get(0);

	    formRepositoryService.createDeployment()
			    .name(file.getName())
			    .parentDeploymentId(idDeployParent)
	            .deploy();

	    System.out.println(" FORMS FOUND: " + formRepositoryService.createFormDefinitionQuery().list().size());
1 Like

Any luck with this one? were you able to resolve it? I’m facing the bery same issue here and got stucked