AnsweredAssumed Answered

spring automatic resource deployment bug ?

Question asked by heymjo on Nov 15, 2011
Latest reply on Nov 16, 2011 by heymjo
Hi,

I think there is a glitch in the way automatic resource deployment works, hopefully someone can prove me wrong.

With below configuration activiti will automatically deploy a processdefinition called validate.bpmn20.xml from the my/app/act location:

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  …
  <property name="deploymentResources" value="classpath*:/my/app/act/validate.bpmn20.xml" />
</bean>

However, what the deployment also does is generate an image for that processdefinition and add it to the list of resources for that deployment in the database. Now next time when i restart my application, Activiti compares the actual deployment resources (the single validate.bpmn20.xml) against the database deployment resources (validate.bpmn20.xml + something like validate.png), sees that they're not the same and redeploy. It will do this forever because i never have the image locally. See DeployCmd#deploymentsDiffer:


  protected boolean deploymentsDiffer(DeploymentEntity deployment, DeploymentEntity saved) {
    Map<String, ResourceEntity> resources = deployment.getResources();
    Map<String, ResourceEntity> savedResources = saved.getResources();
    if (!resources.keySet().equals(savedResources.keySet())) {
      // !!! this is always the case because the auto-generated image is not there locally !!!
      return true;
    }
    for (String resourceName: resources.keySet()) {
      ResourceEntity resource = resources.get(resourceName);
      byte[] bytes = resource.getBytes();
      ResourceEntity savedResource = savedResources.get(resourceName);
      byte[] savedBytes = savedResource.getBytes();
      if (!Arrays.equals(bytes, savedBytes)) {
        return true;
      }
    }
    return false;
  }

I can see this code working fine for deployment archives, but not when you just pack a processdefinition in an application jar file and deploy from there.

Thanks

Outcomes