创建部署时出错 => ENGINE-16004 关闭命令上下文时出现异常:null

Error while creating deployment => ENGINE-16004 Exception while closing command context: null

异常的完整堆栈跟踪如下,

2021-02-11 16:28:52.475 [NBIN0060] [http-nio-8560-exec-5] ERROR org.camunda.bpm.engine.context@logError:160 - ENGINE-16004 Exception while closing command context: null
java.lang.NullPointerException: null
    at org.camunda.bpm.engine.impl.cmd.GetNextIdBlockCmd.execute(GetNextIdBlockCmd.java:41)
    at org.camunda.bpm.engine.impl.cmd.GetNextIdBlockCmd.execute(GetNextIdBlockCmd.java:28)
    at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
    at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:107)
    at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.doInTransaction(SpringTransactionInterceptor.java:46)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:44)
    at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
    at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
    at org.camunda.bpm.engine.impl.db.DbIdGenerator.getNewBlock(DbIdGenerator.java:49)
    at org.camunda.bpm.engine.impl.db.DbIdGenerator.getNextId(DbIdGenerator.java:41)
    at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.ensureHasId(DbEntityManager.java:688)
    at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.insert(DbEntityManager.java:570)
    at org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:52)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd.deploy(DeployCmd.java:486)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd.call(DeployCmd.java:142)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd.call(DeployCmd.java:130)
    at org.camunda.bpm.engine.impl.interceptor.CommandContext.runWithoutAuthorization(CommandContext.java:482)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd.doExecute(DeployCmd.java:130)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:96)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:76)
    at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
    at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:107)
    at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.doInTransaction(SpringTransactionInterceptor.java:46)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:44)
    at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
    at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
    at org.camunda.bpm.engine.impl.RepositoryServiceImpl.deployWithResult(RepositoryServiceImpl.java:102)
    at org.camunda.bpm.engine.impl.repository.DeploymentBuilderImpl.deployWithResult(DeploymentBuilderImpl.java:270)
    at org.camunda.bpm.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:266)

当我尝试执行以下代码时出现上述异常,

final Deployment deployment = repositoryService.createDeployment().addInputStream(fileNamePath, fis)
                .name(deploymentData.getDeploymentName()).tenantId(deploymentData.getTenantId())
                .enableDuplicateFiltering(deploymentData.isEnableDuplicateFiltering()).deploy();

所以这里deploy()方法抛出这个异常。当我在 camunda 代码中对此进行调试时,此异常的确切位置来自 camunda class org.camunda.bpm.engine.impl.cmd.GetNextIdBlockCmd.execute(commandContext)。方法如下,这里 属性 为空,因此 property.getValue() 抛出空值。

  public IdBlock execute(CommandContext commandContext) {
    PropertyEntity property = commandContext
      .getPropertyManager()
      .findPropertyById("next.dbid");
    long oldValue = Long.parseLong(property.getValue());
    long newValue = oldValue+idBlockSize;
    property.setValue(Long.toString(newValue));
    return new IdBlock(oldValue, newValue-1);
  }

我的基本流程图如下, [1]: https://i.stack.imgur.com/9kP4F.png

我找到了问题的解决方案。

出现此异常是因为下面截图中突出显示的 属性 next.dbid 在我的 ACT_GE_PROPERTY table 的 camunda 中丢失了。