Wednesday, February 25, 2009

Embedding Bonita in web applications

It is possible to embed Bonita 4.0.1 on web applications just line it can be done on desktop ones. The basic steps are the same. Here I will describe how to do the deployment on Tomcat 6.0.18:

  1. Add the Bonita libraries in bonita-runtime-4.0.1/lib/server to the application's classpath, except for the servlet-api-2.3.jar library, since this one will conflict with Tomcat's own servlet library. In the case of applications deployed as WAR files in Tomcat, they must be located in the WEB-INF/lib folder.
  2. Add the environment.xml, environment-history.xml, hibernate.properties, hibernate-core.properties and hibernate-history.properties files to the application's classpath. In WAR packages this can be done by adding the files to the WEB-INF/classes folder.
  3. Add the JAR files with your database driver's to Tomcat's lib folder.
  4. Configure your web application to use JAAS security with a login module of your choice. Detailed instructions on how to do that in Tomcat 6.0 are available here.
  5. Modify your JAAS configuration to include the login module required by the Bonita Engine: org.ow2.novabpm.identity.auth.StorageLoginModule. It must be flagged as required and it must be the last in the chain of login modules you have configured for your application. No one of the login modules configured must be flagged as sufficient. If you do so and one of the login modules succeed, the control will return to the application before actually running Bonita's module. This will make the Bonita engine to raise a security exception.
  6. Add the system property org.ow2.bonita.api-type with Standard value to the JAVA_OPTS environment variable. This can be done editing the catalina.bat file found in the bin folder of the Tomcat distribution.
  7. Compile and deploy your application.

In general, Bonita is not affected if deployed embedded in a web application or in a desktop one, as long as the necessary resources are available in the classpath. The only limitation is imposed by the use of a system property to specify the API type (either EJB2, EJB3 or Standard) because it is system wide, meaning that you cannot have in the same Tomcat server an application with Bonita embedded and another with Bonita as a client to a server deployed somewhere else.

8 comment(s):

  1. Hi Luis,

    It's an effective tutorial .

    Thank you
    alis

    ReplyDelete
  2. Hi,
    can you explain how use examples provided with Bonita runtime (approval workflow, websale...) in both standard and entreprise environment please ?
    It is not clear in Bonita doc

    Bonita's user

    ReplyDelete
  3. Hi mmalgare!

    I am glad, you found it useful!

    Thanks,
    Luis!

    ReplyDelete
  4. Hi Luis,
    i've got a web app with bonita-server embedded.
    it perfectly works.
    now i'd like to reuse Bonita Console as GUI to manage workflow.
    do you think it is possible to deploy the Bonita Console onto the same Tomcat? can this two user interfaces work toghether, sharing the same db?
    do you have any idea?
    thanks in advance
    Antonio

    ReplyDelete
  5. Hi Antonio!

    One option (quick and dirty) is to configure the console to access the same database than your application. You need to make sure the Hibernate cache is disable (it is disable by default on Bonita 4.1)

    It is possible to deploy the console in the same Tomcat that your application is using. However, you need to move a lot of stuff and I haven't done that. What I would do (assuming it is possible in your environment) is to deploy the application you created on the Tomcat part of the console.

    Regards,
    Luis!

    ReplyDelete
  6. Hi Luis,

    thank you very much!

    all the best
    Antonio

    ReplyDelete