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

Camunda:InvalidRequestException: Process engine with name camundaProcessEngine does not exist

我创建了 Maven Camunda Java 项目并在 ServletProcessApplication 内部扩展 class 即 MultiTenantProcessApplicationEngine 我创建了一个方法 createProcessEngine() 来注册 processEngine 通过 java API 和 MSSQL Database。 我在关注社区问了一个问题linkhttps://forum.camunda.org/t/multi-tenancy-programmatically-create-tenant/2876

我的

DbName:camunda2db,
dbusername:camunda2
dbpassword:camunda2

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

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();
        }
    }

它在 Java 应用程序中工作正常,但是当我登录到 camunda 时 URL:http://localhost:8080/camunda/app/admin/camundaProcessEngine/#/login

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

24-Mar-2018 17:39:33.463 WARNING [http-nio-8080-exec-4] org.camunda.bpm.engine.rest.exception.RestExceptionHandler.toResponse org.camunda.bpm.engine.rest.exception.InvalidRequestException: Process engine with name camundaProcessEngine does not exist
    at org.camunda.bpm.webapp.impl.security.auth.UserAuthenticationResource.doLogin(UserAuthenticationResource.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
    at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:41)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.camunda.bpm.engine.rest.filter.EmptyBodyFilter.doFilter(EmptyBodyFilter.java:97)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilterSecure(SecurityFilter.java:67)
    at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilter(SecurityFilter.java:51)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.execute(AuthenticationFilter.java:58)
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.execute(AuthenticationFilter.java:56)
    at org.camunda.bpm.webapp.impl.security.SecurityActions.runWithAuthentications(SecurityActions.java:40)
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:56)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:409)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

我不知道我在哪里提交 mistake.Please 帮助,任何配置需要和 link 与在 camunda 中以编程方式创建和注册 ProcessEngine 相关。

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

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

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

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

以configure/create中的一个共享引擎为例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