Embedded Form Serialization Error

Hello,

i want to serialize Data from an embedded form into a Java Data Object.
This is the Code of my html Form.

<form name="Versicherungsantrag" role="form">

    <script cam-script type="text/form-script">

        var customerData = $scope.customerData = {};

        camForm.on('form-loaded', function() {
            camForm.variableManager.createVariable({
                name: 'customerData',
                type: 'Object',
                value: customerData,
                valueInfo: {
                    serializationDataFormat: 'application/json',
                    objectTypeName: 'de.mjkd.bpm.model.Person'
                }
            });
        });

    </script>

    <h3>Vertragsdaten: </h3>

    <div class="control-group">
        <label class="control-label" for="firstname">Firstname</label>
        <div class="controls">
            <input id="firstname"
                   class="form-control"
                   type="text"
                   required
                   ng-model="customerData.name">
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="email">Email</label>
        <div class="controls">
            <input id="email"
                   class="form-control"
                   type="email"
                   required
                   ng-model="customerData.email">
        </div>
    </div>


    <div class="control-group">
        <label class="control-label" for="age">Alter<span>*</span></label>
        <input class="controls"
               cam-variable-type="Integer"
               cam-variable-name="age"
               id="age"
               type="number"
                min="18"
                max="100"
                ng-model="customerData.age"/>
    </div>

    <div class="control-group">
        <label class="control-label" for="customerSex">Sex<span>*</span></label>
        <select id="customerSex"
                class="controls"
                required
                cam-variable-type="String"
                cam-variable-name="customerSex"
                ng-model="customerData.gender">
            <option value="männlich" selected>männlich</option>
            <option value="weiblich">weiblich</option>
        </select>
    </div>
</form>

This is the Model Class:

package de.mjkd.bpm.model;

public class Person {

    private String name;
    private String email;
    private int age;
    private String gender = "male";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }
}

If I know enter data into the Form and Submit it there is an error saying:

The process could not be started. : Cannot instantiate process definition Autoversicherung:1:187add85-eafd-11e7-
a295-52540085082f: Cannot find serializer for value 'ObjectValue [value=null, isDeserialized=false, 
serializationDataFormat=application/json, objectTypeName=de.mjkd.bpm.model.Person, serializedValue=64 chars]'.

Did i forget something to get this working?

Also the Form looks a little bit ugly in Firefox. Is this normal?

Did you include the camunda-spin libraries in your pom/gradle file? The starter only uses them as optional, so you have to activate them manually

I have included these dependencies but the error still exists.

<dependency>
        <groupId>org.camunda.spin</groupId>
        <artifactId>camunda-spin-dataformat-json-jackson</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>org.camunda.spin</groupId>
        <artifactId>camunda-spin-core</artifactId>
        <version>1.3.1</version>
    </dependency>

Hm. Could you post a minimal “working” example on github?

I have pushed an “working/failure” example to my Github page.

This is the Link to the Repository

https://github.com/KevDi/autoversicherung

The Branch helpExample is the Example which crashes.
You have to run mvn clean install and run the jar.
To Login use the User “antragsteller” with the password “antragsteller” and start the Task “Autoversicherung”.

I think i know whats wrong. But i don’t know how to do it.

The Spring Boot Starter run’s an embedded Tomcat. I think i have to activate the Spin Plugin for Tomcat. If i download the Tomcat Server from Camunda there is a File called bpm-platform.xml. In this file there is a plugin definition:

 <!-- plugin enabling integration of camunda Spin -->
<plugin>
        <class>org.camunda.spin.plugin.impl.SpinProcessEnginePlugin</class>
</plugin>

so i have to add this to the embedded Tomcat but i don’t know how.

The plugin is discovered automatically by the starter - if its present. So this was the right idea, you have to add

 <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine-plugin-spin</artifactId>
            <version>7.8.0</version>
        </dependency>

to your pom. You know see the SpinPlugin in the list of used configuration plugins:

2017-12-28 13:42:26.260 INFO 35007 --- [ main] org.camunda.bpm.engine.cfg : ENGINE-12003 Plugin 'CompositeProcessEnginePlugin[genericPropertiesConfiguration, ..., SpinProcessEnginePlugin]' activated on process engine 'default'

2 Likes

Thank you very much. This solves the Problem. :smiley::+1: