# AppEngine programmatic linking to ProcessEngine

**URL:** <https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729>\
**Category:** Flowable Engine\
**Created:** [October 13, 2018, 3:22pm UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729 "2018-10-13T15:22:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruzkant](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ruzkant](https://forum.flowable.org/u/ruzkant)\
**Post date:** [October 13, 2018, 3:22pm UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/1 "2018-10-13T15:22:50Z")

</div>

I have a spring application (not boot) that uses java config for the process engine, but also hosts the rest api for the modeler webapp to deploy app definitions. Now with the new AppEngine I needed to deploy the app engine rest services in my application. This works fine, but it only deploys to the act\_app tables if not linked to the process engine, which I don’t know how to do.

```auto
    @Bean
    public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
        SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
        config.setDataSource(dataSource);
        config.setTransactionManager(transactionManager);
        ... some more config

        // configurators
        ArrayList<EngineConfigurator> configurators = new ArrayList<>(2);
        configurators.add(new SpringFormEngineConfigurator());
        configurators.add(new SpringContentEngineConfigurator());
        config.setConfigurators(configurators);
        
        ... some more config like parse handlers
        return config;
    }

    @Bean
    public ProcessEngine processEngine(ProcessEngineConfiguration config) {
        return config.buildProcessEngine();
    }

```

So the above configures the process engine, and adding the configurators also hooks up the Form and Content engines.

There is however no SpringAppEngineConfigurator to add to the configurators.

```auto
   @Bean
    public AppEngineConfiguration appEngineConfiguration(ProcessEngine processEngine, ProcessEngineConfiguration processEngineConfiguration, DataSource dataSource, PlatformTransactionManager transactionManager) {
        SpringAppEngineConfiguration appEngineConfiguration = new SpringAppEngineConfiguration();
        appEngineConfiguration.setDataSource(dataSource);
        appEngineConfiguration.setDatabaseSchemaUpdate(AppEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        appEngineConfiguration.setTransactionManager(transactionManager);
        appEngineConfiguration.setDisableIdmEngine(true);
        // THIS AT LEAST DEPLOYS TO FORM ENGINE
        appEngineConfiguration.setConfigurators(processEngineConfiguration.getConfigurators());

        return appEngineConfiguration;
    }

    @Bean
    public AppEngineFactoryBean appEngineFactoryBean(AppEngineConfiguration appEngineConfiguration) {
        AppEngineFactoryBean factoryBean = new AppEngineFactoryBean();
        factoryBean.setAppEngineConfiguration(appEngineConfiguration);
        return factoryBean;
    }

    @Bean
    public AppEngine appEngine(AppEngineFactoryBean appEngineFactoryBean) {
        try {
            return appEngineFactoryBean.getObject();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

```

So while I can grab the other configurators from the processEngineConfiguration and it does deploy to the form engine, I can’t get deployment of processes working.

I have also tried: appEngineConfiguration.setCustomPostDeployers(Arrays.asList(new BpmnDeployer()));  
But gets NullPointer here: CommandContextUtil.getProcessEngineConfiguration().getRepositoryService();

I don’t understand enough of the guts here to know where to plug it in.

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [October 13, 2018, 4:35pm UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/2 "2018-10-13T16:35:25Z")

</div>

I would advise you to look at the [`ProcessEngineAutoConfiguration`](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/ProcessEngineAutoConfiguration.java) to see how this is done with Spring Boot. More precisely the `ProcessEngineAppConfiguration` within the auto configuration.

You should not build the process engine like you are doing it when it is standalone. There is a `ProcessEngineConfigurator` and you need to add that to the `AppEngine`.

Then in order to expose the `ProcessEngine` you need to do something like in the [`ProcessEngineServicesAutoConfiguration`](https://github.com/flowable/flowable-engine/blob/master/modules/flowable-spring-boot/flowable-spring-boot-starters/flowable-spring-boot-autoconfigure/src/main/java/org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.java#L69) more precisely the `AlreadyInitializedAppEngineConfiguration`.

---

<div class="post-metadata">

**Author:** ![ruzkant](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ruzkant](https://forum.flowable.org/u/ruzkant)\
**Post date:** [October 13, 2018, 5:48pm UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/3 "2018-10-13T17:48:46Z")

</div>

Thanks. I had a brief look at those classes before I posted, but it will take me a bit of time to understand all the inter-relationships.

Let me phrase it differently…

How would you connect the app engine to a non-spring standalone process engine as here?

```auto
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration" class="org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration">

    <property name="jdbcUrl" value="jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />

    <property name="databaseSchemaUpdate" value="true" />

    <property name="asyncExecutorActivate" value="false" />

    <property name="mailServerHost" value="mail.my-corp.com" />
    <property name="mailServerPort" value="5025" />
  </bean>

</beans>

```

Taken from here: [https://www.flowable.org/docs/userguide/index.html#configuration](https://www.flowable.org/docs/userguide/index.html#configuration)

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [October 15, 2018, 6:09am UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/4 "2018-10-15T06:09:35Z")

</div>

> Thanks. I had a brief look at those classes before I posted, but it will take me a bit of time to understand all the inter-relationships.

The Spring Boot auto configuration would be the same way I would do a non Spring Boot application and a non spring application.

In that XML you will need to create an additional `appEngineConfiguration`, add a `processEngineConfigurator` and add it to the `appEngineConfiguration`. and then use `AppEngines` to get the `AppEngine`. This would trigger an initialisation of the `ProcessEngine` as well

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![ruzkant](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ruzkant](https://forum.flowable.org/u/ruzkant)\
**Post date:** [October 20, 2018, 4:53am UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/5 "2018-10-20T04:53:52Z")

</div>

Hi Filip

Apologies. I should have just read your first answer more carefully as there was enough information to resolve my issue. Took a few minutes to rearrange my configuration.

The AppEngine should be driving the configuration and other configurators added to it.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [October 20, 2018, 10:17am UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/6 "2018-10-20T10:17:27Z")

</div>

No problem @ruzkant. I should have been clearer as well. Glad that you resolved your problem.

Yes in this case the AppEngine is the one leading the configurations.

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![ruzkant](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ruzkant](https://forum.flowable.org/u/ruzkant)\
**Post date:** [October 21, 2018, 2:56pm UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/7 "2018-10-21T14:56:49Z")

</div>

By the way I found a problem with the app deployment code where version numbers were not increased…

See here: [https://github.com/flowable/flowable-engine/pull/1356](https://github.com/flowable/flowable-engine/pull/1356)

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [October 22, 2018, 6:07am UTC](https://forum.flowable.org/t/appengine-programmatic-linking-to-processengine/2729/8 "2018-10-22T06:07:23Z")

</div>

Thanks for the PR @ruzkant. Tijs already merged it
