AnsweredAssumed Answered

deployment didn't put process definition in the cache

Question asked by gguimezanes on Dec 11, 2012
Latest reply on Dec 19, 2012 by jbarrez
Hello
I am trying to deploy a process definition, not from a BPML file, but from a ProcessDefinitionEntity that I created programmatically.
When I test deploying my process, creating an instance of it, listing and completing tasks, all in the same standalone process engine execution, it works like a charm.
However, if I run another test that constructs a new standalone process engine (with the same configuration file) and I try to list tasks for the process I created previously, I get the following Exception:
org.activiti.engine.ActivitiException: deployment '1' didn't put process definition '2' in the cache
If I run the activity explorer, I can see my deployment and my process definition, however when I click on "start process" I get the same exception.

Here is the execute method of my deploy command (toDeploy is a ProcessdefinitionEntity that is given as parameter of the command)… as you see I put the ProcessdefinitionEntity in the cache, which explains why I don't get the exception when I manipulate the process in the same engine execution as the deployment.


@Override
    public Void execute(CommandContext commandContext) {

        DbSqlSession dbSqlSession = commandContext.getSession(DbSqlSession.class);

        DeploymentEntity deploymentEntity = new DeploymentEntity();
        deploymentEntity.setName(toDeploy.getName());
        deploymentEntity.setNew(true);
        dbSqlSession.insert(deploymentEntity);

        int versionNumber = computeVersion(commandContext);
        toDeploy.setVersion(versionNumber);
        toDeploy.setDeploymentId(deploymentEntity.getId());

        dbSqlSession.insert(toDeploy);

        Context.getProcessEngineConfiguration().getDeploymentCache().addProcessDefinition(toDeploy);
        return null;
    }

Do you know what I should do so that the deployment cache is correctly loaded when I start a new process engine? Is it something I should add in my deployment command, or something I should do when starting my new process engine?

I start the engine this way (using the default activiti.cfg.xml using a standalone h2 database):

ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
I use my command this way:

((ProcessEngineConfigurationImpl) processEngineConfiguration).getCommandExecutorTxRequired().execute(
                myDeployCommand);

Thanks.

Outcomes