Activiti + Mule ESB – Part 2


In the first part of this post we show how to start an Activiti process from Mule ESB using the new Mule’s activiti module. In this part we are going to show how to call a Web Service from Activiti that is going to be contained in Mule. Notice that you can expose anything as a Web service in Mule such as: beans, queues, etc.

Activiti configuration

First of all we need to create our proces. It will receive a request containing the username that has requested the image and the image name. The process will work as follows: check if the image needs copyright; if it needs copyright then allow the owner to approve or disapprove the request. If the request is approved, then charge the requester otherwise cancel it. In case that the image doesn’t need approval, just charge the requester with the cost.

The following process definition follows the logic described above (Fig. 1):

Fig. 1. Picture request process definition

Fig. 1. Picture request process definition

The process definition uses 2 delegates to check whether an image has copyright and to call the Web service in Mule. In the first case we have created the following simplified Java class for it:

The other Java delegate calls the Web service in Mule (using the approach presented by Bernd as Activiti doesn’t support calls to web services yet). Next we outline the class:

You need to deploy the following 2 classes as explained in the User guide by copying the jar to ${activiti distro}/apps/apache-tomcat-6.0.29/webapps/activiti-rest/lib/. You can download the project for the extensions from here; the project is under the activiti-extensions directory.

Finally, we need to upgrade our form to allow the user to approve or disapprove the request using a select element as shown next:

We are almost done with Activiti; just delete the previous version of the definitions and upload the new version using Activiti-probe (the new definitions are under the activiti-picture-example directory). Next we will show how to create the Web service in the Mule side.

Mule configuration

Now all we need to do is extend the previous Mule configuration from part 1 and add a new flow exposing the Web service.

We have also added some ajax configuration so that we can notify our user when the request has been approved (either automatically or manually). You can see a picture of the notification of Fig. 2.

Fig. 2. Picture request approved

Fig. 2. Picture request approved

As it’s an exemplar application we implement the following stub Web service to check everything works as expected by just returning the image name that will be push to the ajax channel:

You can download the complete Mule project here and browse the source here.  You can start the project by setting your MULE_HOME variable and running mvn clean install from the root of the project. Also, don’t forget to publish the Activiti deployment zip file under the activiti-picture-example directory.

Don’t have time to deploy it? Try this short video:

[yframe url=’’]

Hope you like this post and I’m looking forward to your comments.

We'd love to hear your opinion on this post

5 Responses to “Activiti + Mule ESB – Part 2”

  1. Hi Esteban,

    thanks for your cool samples. I tried to get them to work with Activiti 5.2 but it failed.
    I deployed the process via activiti-probe,
    I copied the picture-request-activit.jar to the activiti-rest/web-inf/lib folder and finally
    I deployed the file to mule

    I start Activiti and Mule and then I go to the Sample Application (localhost:8999), I choose one
    picture and click the Request image button -> I get an error in the tomcat log.
    The Process Definition can’t be found with the given ID=pictureRequest:1, I saw in the database tables
    that since Activiti 5.2 the ID has another number after the version 1, in my case it is pictureRequest:1:113.
    In Activiti 5.0 and 5.1 it was still pictureRequest:1.
    I also tried the versions 5.0 and 5.1 but I get the same error. I only use the H2 database, perhaps this is
    the problem.

    Which configuration did you use (Activiti version, database)?


    18.02.2011 08:23:00 org.activiti.engine.impl.interceptor.CommandContext close
    SCHWERWIEGEND: Error while closing command context
    org.activiti.engine.ActivitiException: no deployed process definition found with id ‘{imageName=mule1.jpg, user=mulee, processDefinitionId=pictureRequest:1}’
    at org.activiti.engine.impl.db.DbRepositorySession.findDeployedProcessDefinitionById(
    at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(
    at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(
    at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(
    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(
    at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(
    at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(
    at org.springframework.extensions.webscripts.PresentationContainer.executeScript(
    at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(
    at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(
    at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(
    at javax.servlet.http.HttpServlet.service(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.http11.Http11Processor.process(
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

  2. Hi Rainer,
    It’s good to hear that you tried the example. I have to mentioned that I tested it with Activiti 5.0/5.1 so you will have to modify your mule config to set the right process definition id.
    Check the first part of this post and change:

    map.put(“processDefinitionId”, “pictureRequest:1”) //the id of the definition


    map.put(“processDefinitionId”, “pictureRequest:1:113”) //the id of the definition

    It shouldn’t be a problem of the database. I tried it with the demo.setup ant task.

  3. Hi Esteban,

    thanks for your answer. Example works great now ;-))
    It was my failure. I deployed the wrong project to mule. I took mule-transport-activiti.jar instead of mule-module-activiti-3.1.0.jar.

    Thanks for this excellent job,

  4. Hi, Thanks for this very nice post !
    I have flowed all the steps but i am getting this error while Kermit is trying to complete the task ! :

    Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier ‘approvalConfirmed’

    am i missing something ?

  5. Hi Esteban,
    very nice post but it should be updated to the latest versions.
    In the meantime both Mule and Activiti versions has been changed that implies pom.xml, mule flows, activiti forms etc modifications.
    I spent some days to fix those problems and finally I got it running with mule 3.2.1 and activiti 5.8.

    So at this point I don’t understand if this combination of technologies should be used for a real project. From theoretical point of view, the architecture make sense but in practice it seems a nightmare to develop and manage an application that is stable and running.

    What do you think? Which are the benefits to use those technologies in a real project? I read the posts that you mentioned at the beginning but they explain the benefits only from theoretical point of view.