How to use Bonita bundles in NetBeans IDE

As explained previously in the articles How to use Bonita bundles in IntelliJ IDEA and How to use Bonita bundles in Eclipse, when developing an application, it is common practice to embed the server in the integrated development environment.
In this article, we’ll see how to do this in Netbeans IDE. Note: everything has been tested using BOS 5.6.2 and Netbeans IDEA 7.1

Follow these steps:

As before, download the BOS-Tomcat bundle from the BOS download page (from the Bundles tab) and unzip it.

Name the bundle BOS_INSTALL.

(Everything else will be done in Netbeans IDE).

Download Netbeans IDE and launch it.

Create a new project (Ctrl+Maj+N) and select Java Web >Web Application

Click on Next and enter the name and location for the new project.

Click on Next again.

In Server and Settings, add a new server by clicking on the Add button.

Select Apache Tomcat and name it BOS installation, for example.

In the next form, select BOS_INSTALL as the server location and enter a name/password for the manager of Tomcat.

Click on Finish to add the server and Finish again to end the new project creation.

Right click on the project name and select its Properties.

Select the item Libraries and click add JAR/Folder.

Add the file bonita-client-5.6.jar you can find in BOS_INSTALL/lib/bonita

As the dependency is provided by the bundle, de-select Package.
In this way, it won’t be embedded in the generated app.

Now, in the index.jsp, let’s create a simple code to list all the deployed processes in the engine.
Here’s the code :

[cc lang=“java”]

<%@page import=“org.ow2.bonita.light.LightProcessDefinition”%>
<%@page import=“org.ow2.bonita.util.AccessorUtil”%>
<%@page import=“org.ow2.bonita.facade.QueryDefinitionAPI”%>
<%@page import=“org.ow2.bonita.util.SimpleCallbackHandler”%>
<%@page import=“javax.security.auth.login.LoginContext”%>
<%@page contentType=“text/html” pageEncoding=“UTF-8”%>

JSP Page

Deployed processes

    <% LoginContext loginContext = new LoginContext("BonitaStore", new SimpleCallbackHandler("user", "")); loginContext.login(); QueryDefinitionAPI queryDefinitionAPI = AccessorUtil.getQueryDefinitionAPI();
                for (LightProcessDefinition lightProcessDefinition : queryDefinitionAPI.getLightProcesses()) {
                    out.println("<li>"+lightProcessDefinition.getName()+"</li>");
                }
                loginContext.logout();
    

    %>


[/cc]

When you execute the project (F6), the following window should be displayed in your browser: