Thursday, August 11, 2011

Install Bonita BPMS 5.4.2 with JBoss 6

(also tested with Bonita 5.5)

Bonita API tutorials
http://www.bonitasoft.org/blog/tutorial/building-your-applications-with-bonita-runtime-part-1/
http://www.bonitasoft.org/blog/tutorial/building-your-applications-with-bonita-runtime-part-2/
http://www.bonitasoft.org/blog/tutorial/building-your-applications-with-bonita-runtime-%E2%80%93-part-3/

Bonita installation tutorials
http://www.bonitasoft.org/wiki/doku.php
http://www.bonitasoft.org/wiki/doku.php?id=install_bos5.3_in_jboss

==============================

Installation:
- download Bonita 5.4.2 + JBoss 5.1 bundle

- copy bonita-app.war bonita.ear bonita.war to JBOSS_HOME/server/default/deploy/

- rename bonita.war to bonita-web.war
new administration path - http://127.0.0.1:8080/bonita-web/
(otherwise JBoss 6 generate exception because two appication with similar name.)

copy folders bonita/client bonita/server/ from bundle to JBOSS_HOME/


add Bonita configuration lines to  JBOSS_HOME/bin/run.conf

#Sets Bonita configuration variables
BONITA_OPTS="-DBONITA_HOME=../bonita -Dorg.ow2.bonita.api-type=EJB3 "
MEMORY_OPTS="-Xshare:auto -Xms512m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError"
LOG_OPTS="-Djava.util.logging.config.file=../external/logging/logging.properties"
JAVA_OPTS="$JAVA_OPTS $BONITA_OPTS $MEMORY_OPTS $LOG_OPTS"
export JAVA_OPTS

- if your start directory is not $JBOSS_HOME/bin then you must add absolute path to BONITA_HOME, for example -DBONITA_HOME=/opt/jboss-6.0.0.Final/bonita


- add security configuration to JBoss:
Add to $asDomain\conf\login-config.xml inside <policy> tags:

<!-- Config for Bonita -->
<application-policy name="BonitaAuth">
          <authentication>
            <login-module code="org.ow2.bonita.identity.auth.BonitaIdentityLoginModule" flag="required"/>
          </authentication>
</application-policy>
<application-policy name="BonitaStore">
          <authentication>
            <login-module code="org.ow2.bonita.identity.auth.BonitaRemoteLoginModule" flag="required"/>
            <login-module code="org.jboss.security.ClientLoginModule" flag="required">
             <module-option name="password-stacking">useFirstPass</module-option>
           </login-module>
          </authentication>
</application-policy>
<!-- End config for bonita -->


==============================

Libraries:

- add

bonita-client-5.4.2.jar
jaxrs-api-1.2.1.GA.jar

to $JBOSS_HOME/client


- replace slf4j-api with version 1.6.1 (latest)

- replace hibernate-search with version 3.4.Final (latest) and move to /common/lib/

- replace lucene-core with version 3.1 (latest) and move to /common/lib/
- replace lucene-analyzers with version 3.1 (latest) and move to /common/lib/


bonita.war
- remove asm.jar
commons-codecs
commons-io
commons-logging
slfj
xstream


remove all hibernate & lucene libraries from bonita.ear WEB-INF/lib
(I removed all libraries from bonita.ear WEB-INF/lib)

==============================

Source code changes:

- make 2 changes in org.ow2.bonita.search.SearchUtil java class:

1 - recompile SearchUtil with hibernate-search-3.4.jar in dependencies
2 - remive (comment) all hibernate search hanlers regishtations

You can find SearchUtil.java here:
http://svn.bonitasoft.org/bonita-runtime/tags/bonita-runtime-5.4/bonita-server/src/main/java/org/ow2/bonita/search/SearchUtil.java
and SearchUtil.class in bonita.ear:bonita-ejbjar.jar

rebuild with hibernate-search-3.4.jar in dependencies and pack back to bonita.ear:bonita-ejbjar.jar

==============================

Switch from H2 to PostgreSQL database (optional):

- create PostgreSQL Bonita databases:

createdb -h localhost -U postgres -E UTF8 bonita_journal
createdb -h localhost -U postgres -E UTF8 bonita_history

(Bonita will self-create tables)

- copy postgresql JDBC driver jar file to JBOSS_HOME/server/default/lib/

- remove $JBOSS_HOME/server/default/deploy/h2-ds.xml
- create Bonita database configuration file $JBOSS_HOME/server/default/deploy/postgres-ds.xml

with text:
<?xml version="1.0" encoding="UTF-8"?>

<datasources>
  <no-tx-datasource>
    <jndi-name>bonita/default/journal</jndi-name>
    <connection-url>jdbc:postgresql://localhost/bonita_journal</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>postgres</user-name>
    <password></password>
    <idle-timeout-minutes>0</idle-timeout-minutes>
  </no-tx-datasource>

  <no-tx-datasource>
    <jndi-name>bonita/default/history</jndi-name>
    <connection-url>jdbc:postgresql://localhost/bonita_history</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>postgres</user-name>
    <password></password>
    <idle-timeout-minutes>0</idle-timeout-minutes>
  </no-tx-datasource>

</datasources>

Edit these files (comment H2 parts and uncomment PostgreSQL parts)
jboss-6.0.0.Final/bonita/server/default/conf/bonita-history.properties
jboss-6.0.0.Final/bonita/server/default/conf/bonita-journal.properties
(there is bug - PostgreSQL port 5432 written as 5433 - you must replace to 5432)

....

Profit!