首页 > 解决方案 > 创建部署时出错 => ENGINE-16004 关闭命令上下文时出现异常: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$1.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$1.call(DeployCmd.java:142)
    at org.camunda.bpm.engine.impl.cmd.DeployCmd$1.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$1.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 类 org.camunda.bpm.engine.impl.cmd.GetNextIdBlockCmd.execute(commandContext)。方法如下,这里属性为null,因此property.getValue()抛出null。

  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

标签: bpmncamunda

解决方案


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

出现此异常是因为我的 camunda 表中next.dbid缺少以下屏幕截图中突出显示的属性。ACT_GE_PROPERTY

https://i.stack.imgur.com/gL867.png


推荐阅读