cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between DeploymentBuilderImpl.add* methods

tstephen
Champ on-the-rise
Champ on-the-rise
I have always assumed that the various DeploymentBuilderImpl.add* methods were equivalent but apparently in 5.13 SNAPSHOT they are not (I have not gone back to check earlier versions).

Specifically this deploys correctly:

      Deployment deployment = createDeployment().addClasspathResource(resource).deploy();


and this does not:

      String resourceName = "test";
      InputStream inputStream = ReflectUtil.getResourceAsStream(resource);
      byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
      Deployment deployment = deploy((DeploymentBuilderImpl) createDeployment()
     .addString(resourceName, definition.trim()));


Note that
resource
is the same in both cases. To be honest I was already pretty close by the time I figured this out having first spent ages investigating how I must have corrupted the String on the wire somehow!

It all comes down to this line in BpmnDeployer:

    if (isBpmnResource(resourceName)) {
      … parse the resource etc..
    }


Apparently because my resource is named 'test' it will never be parsed or the process definition stored! If I call it 'test.bpmn' all is well.

So what is the intent on this line? I suppose someone was trying to protect against an attempt to parse a non-BPMN resource but if I do feed a garbage string into the parser it gives a pretty reasonable exception (org.activiti.engine.ActivitiException: Error parsing XML).

Anyone object to simply removing the check?
Cheers,
Tim
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
Hi Tim, sorry for the late response. Really busy lately.

Regarding your problem: yes it has hit me too in the past.
The problem is that in theory, you can upload any resource to a deployment (images, word docs, etc.) and they will all be stored in the database for later retrieval.

Maybe is a dedicated, new method, specifically for the process xml is a good solution (not breaking backwards compatibility)?