Tuesday, March 31, 2009

Connecting to Bonita in an AS (part II)

Once the Bonita Runtime engine is deployed in an application server, it can be accessed from a remote client or from applications running in the same server, like EJBs, Web Modules (JSPs, Servlets, JSF, etc.) or Web Services.

To access the engine from the same application server you need to:

  1. Create the client J EE application
  2. Include the Bonita Client library
  3. Set the org.ow2.bonita.api-type variable
  4. Deploy the client application

Create the client J EE application

First, you need to code your application, as described in the Cookbook document. The Bonita API is designed in such a way that your code will not need to change if you move from an embedded engine to one deployed in an application server or vice versa.

Include the Bonita Client library

The Bonita API classes need to be included in your application's classpath.

At this point, it is important to understand correctly the class loading policy configured in the target environment. If the classes of the deployed applications are isolated from each other you will need to include the bonita-client-4.1.jar library in your application's classpath.

However, if the target application server has a flat class pool (like JBoss' default settings), including the Bonita client library will generate exceptions (usually ClassCastException) when trying to use the Bonita API. This is because some of the classes in the client library are present as well in the bonita.ear file and the application server will not know which one to use.

In that case, you have 2 options. The first one is to make sure the bonita-client-4.1.jar library is NOT included in your application (avoiding the duplication of deployed classes). The other option is to reconfigure your environment to isolate the classes of different application packages.

Set the org.ow2.bonita.api-type variable

Since you are working with a Bonita engine deployed in an application server, you need to set the org.ow2.bonita.api-type system property to the corresponding value. It will be either EJB2 or EJB3, according to the type of EJB container that you are using. It should match the Ant task used to create the bonita.ear file: ear.ejb2 or ear.ejb3.

Deploy the client application

Once you have coded and build your application and your environment is ready, the final step is to deploy it. There are not special considerations required when using Bonita, so you just need to follow the instructions of your vendor. In JBoss, you will need to copy your application package (EAR, JAR or WAR) into the deploy folder and the server will take care of everything else.

0 comment(s):

Post a Comment