title: How to declare an Activiti custom FormType in a Spring Boot application
body: <p>I have a Spring Boot application that is running workflows using the Activiti framework. I have got to the point where I need to create a new FormType so that I can support a field in the workflow more complex than a String/Long etc.</p>
  
  <p>The article I have been following is <a href="http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/" rel="nofollow">http://www.jorambarrez.be/blog/2013/03/13/creating-a-new-form-property-in-activiti/</a></p>
  
  <p>My form type is declared as</p>
  
  <pre><code>public class PurchaseOrderFormType extends AbstractFormType {
  
      private static final String FORM_TYPE = "purchaseorder";
  
      private String name;
      private String supplier;
      private String shippingAddress;
      private String billingAddress;
      private String issuedByAddress;
  
      private List&lt;PurchaseOrder&gt; purchaseOrders;
  
      public String getSupplier() {
          return supplier;
      }
  
      public void setSupplier(String supplier) {
          this.supplier = supplier;
      }
  
      public String getShippingAddress() {
          return shippingAddress;
      }
  
      public void setShippingAddress(String shippingAddress) {
          this.shippingAddress = shippingAddress;
      }
  
      public String getBillingAddress() {
          return billingAddress;
      }
  
      public void setBillingAddress(String billingAddress) {
          this.billingAddress = billingAddress;
      }
  
      public String getIssuedByAddress() {
          return issuedByAddress;
      }
  
      public void setIssuedByAddress(String issuedByAddress) {
          this.issuedByAddress = issuedByAddress;
      }
  
      public List&lt;PurchaseOrder&gt; getPurchaseOrders() {
          return purchaseOrders;
      }
  
      public void setPurchaseOrders(List&lt;PurchaseOrder&gt; purchaseOrders) {
          this.purchaseOrders = purchaseOrders;
      }
  
      @Override
      public String getName() {
          return FORM_TYPE;
      }
  
      @Override
      public Object convertFormValueToModelValue(String propertyValue) {
          PurchaseOrderFormType purchaseOrderFormType = new PurchaseOrderFormType();
          ObjectMapper objectMapper = new ObjectMapper();
  
          try {
              purchaseOrderFormType = objectMapper.readValue(propertyValue,
                  PurchaseOrderFormType.class);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          return purchaseOrderFormType;
      }
  
      @Override
      public String convertModelValueToFormValue(Object modelValue) {
          ObjectMapper objectMapper = new ObjectMapper();
          try {
              return objectMapper
                  .writeValueAsString((PurchaseOrderFormType) modelValue);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          return null;
      }
  }
  </code></pre>
  
  <p>The PurchaseOrder class hasn't been included here to simplify the question. It is just a POJO.</p>
  
  <p>I attempted to load the form type in my spring boot application using the command line runner below, however, this appears to be too late because when I use this type in a workflow that is being loaded automatically by spring-boot the type isn't yet loaded and an exception is thrown. This exception is thrown before the initProcessEngine has been called and I've verified this in the debugger.</p>
  
  <pre><code>@Bean
  public CommandLineRunner initProcessEngine(final ProcessEngineConfiguration processEngineConfiguration) {
      return new CommandLineRunner() {
          @Override
          public void run(String... strings) throws Exception {
              List&lt;AbstractFormType&gt; customFormTypes = new ArrayList&lt;AbstractFormType&gt;();
              customFormTypes.add(new PurchaseOrderFormType());
          }
      };
  }
  </code></pre>
  
  <p>How can I perform the equivalent of the configuration below provided in the linked article using spring boot XML free configuration?</p>
  
  <pre><code>&lt;bean id="processEngineConfiguration" ... &gt;
    ...
    &lt;property name="customFormTypes"&gt;
      &lt;list&gt;
        ...
        &lt;bean class="com.marc.PurchaseOrderFormType"/&gt;
      &lt;/list&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>