Search code examples
bpmncamunda

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


The full stack trace of the exception is as below,

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)

Above exception is coming when I try to execute below code,

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

So here deploy() method throws this exception. When I debugged this in camunda code the exact place of this exception is from camunda class org.camunda.bpm.engine.impl.cmd.GetNextIdBlockCmd.execute(commandContext). The method is as below and here property is null, and because of this property.getValue() throws 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);
  }

My basic process diagram is like below, [1]: https://i.sstatic.net/9kP4F.png


Solution

  • I got the solution to my problem.

    This exception is coming because the highlighted property next.dbid in the below screenshot was missing in my ACT_GE_PROPERTY table of camunda.

    https://i.sstatic.net/gL867.png