Camunda:InvalidRequestException:名称为camundaProcessEngine的进程引擎不存在

时间:2018-03-24 14:24:11

标签: camunda

我创建了Maven Camunda Java Project和contentEquals(CharSequence)扩展类,ServletProcessApplication我创建了一个方法MultiTenantProcessApplicationEngine,通过java API注册createProcessEngine() processEngine }。 我正在关注社区问一个问题链接https://forum.camunda.org/t/multi-tenancy-programmatically-create-tenant/2876

我的

MSSQL Database

除了以下代码完全没有,我做了任何配置:

DbName:camunda2db,
dbusername:camunda2
dbpassword:camunda2

它在Java应用程序中运行良好,但是当我登录到camunda时 使用网址:http://localhost:8080/camunda/app/admin/camundaProcessEngine/#/login

抛出异常:InvalidRequestException:名称为camundaProcessEngine的流程引擎不存在

package com.camundatest;
    import org.apache.log4j.Logger;
    import org.camunda.bpm.application.ProcessApplication;
    import org.camunda.bpm.application.impl.ServletProcessApplication;
    import org.camunda.bpm.container.RuntimeContainerDelegate;
    import org.camunda.bpm.engine.ProcessEngine;
    import org.camunda.bpm.engine.ProcessEngineConfiguration;

    @ProcessApplication
    public class MultiTenantProcessApplicationEngine extends ServletProcessApplication{

          private final static Logger LOGGER = Logger.getLogger(MultiTenantProcessApplicationEngine.class);
          private void createProcessEngine(){
              LOGGER.info("\n\n**********Creating ProcessEngine *********");
              ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
                      .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
                      .setJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")
                      .setJdbcUrl("jdbc:sqlserver://localhost:1433;databaseName=camunda2db")
                      .setJdbcUsername("camunda2")
                      .setJdbcPassword("camunda2")
                      .setJobExecutorActivate(true)
                      .setProcessEngineName("camundaProcessEngine")
                      .setHistory(ProcessEngineConfiguration.HISTORY_FULL)
                      .buildProcessEngine();

              RuntimeContainerDelegate runtimeContainerDelegate = RuntimeContainerDelegate.INSTANCE.get();

              runtimeContainerDelegate.registerProcessEngine(processEngine);
              LOGGER.info("\n\n Process Engine: "+processEngine);
          }

          public static void main(String[] args) {
              MultiTenantProcessApplicationEngine appProcessEngine = new MultiTenantProcessApplicationEngine();
              appProcessEngine.createProcessEngine();
        }
    }

我不知道我在哪里犯了错误。请帮忙,任何配置需要和链接相关的以编程方式创建并在camunda中注册ProcessEngine。

1 个答案:

答案 0 :(得分:1)

您的类MultiTenantProcessApplicationEngine包含一个main方法,如果直接通过java执行,则会调用该方法,但如果您使用@ProcessApplication注释此类,则永远不会调用main方法。 它只是部署和注册您的应用程序类。

如果您使用tomcat,jboss,wildfly或其他应用程序服务器,则应使用共享引擎。您可以阅读有关不同引擎引导here的信息。

通过您的方法,您将创建一个嵌入式引擎。

如果您想了解不同的运行时容器集成,请阅读此documentation

例如,要在jboss / wildfly中配置/创建共享引擎,您必须向standalone.xml添加子系统。

这可能是这样的:

<subsystem xmlns="urn:org.camunda.bpm.jboss:1.1">
    <process-engines>
        <process-engine name="engineName" default="true">
            <datasource>java:jboss/datasources/ProcessEngine</datasource>
            <history-level>full</history-level>
            <properties>
                <property name="jobExecutorAcquisitionName">default</property>
                <property name="isAutoSchemaUpdate">true</property>
                <property name="authorizationEnabled">true</property>
            </properties>
        </process-engine>
    </process-engines>
    <job-executor>
        <core-threads>3</core-threads>
        <max-threads>5</max-threads>
        <queue-length>10</queue-length>
        <job-acquisitions>
            <job-acquisition name="default">
                <properties>
                    <property name="lockTimeInMillis">300000</property>
                    <property name="waitTimeInMillis">5000</property>
                    <property name="maxJobsPerAcquisition">3</property>
                </properties>
            </job-acquisition>
        </job-acquisitions>
    </job-executor>
</subsystem>

您可以阅读有关配置步骤here的更多信息。