Wednesday March 22, 2006
How to Run jbpm on SJSAS/Glassfish with Derby
Jbpm is a workflow and business process engine from Jboss, and is
tightly integrated with JBoss appserver. Recently some
people asked if jbpm can run on SJSAS/Glassfish. My first
response is, absolutely, any J2EE/JavaEE applications can run on
SJSAS/Glassfish, with more or less tweaks. So I decided to prove
this with jbpm 3.1 on SJSAS 8.2 and Glassfish. Steps in
this article have been successfully tested with SJSAS 8.2 final
release, and Glassfish build 43 (very close to final release).
Before we start, a few
noteworthy points:
$SJSAS_HOME/domains/domain1/config/domain.xml:<jvm-options>-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy</jvm-options><jvm-options>-Djava.security.manager</jvm-options> (if this line is present)<jvm-options>-Dcom.sun.enterprise.taglibs=appserv-jstl.jar,myfaces-impl.jar</jvm-options>
<jvm-options>-Dcom.sun.enterprise.taglisteners=myfaces-impl.jar</jvm-options>mv
$SJSAS_HOME/lib/jsf-api.jar $SJSAS_HOME/lib/jsf-api.jar.bak
//For SJSAS 8.2 only
mv $SJSAS_HOME/lib/jsf-impl.jar
$SJSAS_HOME/lib/jsf-impl.jar.bak
cp
$JBPM_HOME/lib/jsf/myfaces*.jar $SJSAS_HOME/lib/"myfaces-api.jar,myfaces-impl.jar," to the
beginning of the value of <sysproperty
key="com.sun.aas.classloader.sharedChainJars". You may
also want to remove "jsf-api.jar, jsf-impl.jar" from the
value of this element.cp $JBPM_HOME/lib/commons/commons-fileupload-1.0.jar
$SJSAS_HOME/lib
cp $JBPM_HOME/lib/commons/commons-beanutils-1.6.1.jar
$SJSAS_HOME/lib
cp
$JBPM_HOME/lib/commons/commons-digester-1.5.jar
$SJSAS_HOME/lib
cp
$JBPM_HOME/lib/jboss/commons-logging.jar
$SJSAS_HOME/lib
cp
$JBPM_HOME/lib/jboss/commons-collections.jar
$SJSAS_HOME/lib
cp
$JBPM_HOME/lib/jboss/log4j.jar
$SJSAS_HOME/lib
cp
$CATALINA_HOME/common/lib/commons-el.jar
$SJSAS_HOME/lib <!-- jdbc connection properties -->
<property
name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property
name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property
name="hibernate.connection.url">jdbc:derby://localhost:1527/sun-appserv-samples;create=true</property>
<property
name="hibernate.connection.username">APP</property>
<property
name="hibernate.connection.password">APP</property>mkdir
$JBPM_HOME/src/resources/derby/
cp $JBPM_HOME/src/resources/hsqldb/*
$JBPM_HOME/src/resources/derby/hibernate.dialect=org.hibernate.dialect.DerbyDialect
hibernate.connection.driver_class=org.apache.derby.jdbc.ClientDriver
hibernate.connection.url=jdbc:derby://localhost:1527/sun-appserv-samples;create=true
hibernate.connection.username=APP
hibernate.connection.password=APP
hibernate.show_sql=truemkdir $JBPM_HOME/lib/derby
cp $SJSAS_HOME/derby/lib/*jar $JBPM_HOME/lib/derby/
(You don't need Derby localization jars)<target name="build.webapp" description="builds
jbpm.war">
<ant antfile="build.xml" target="build.webapp"
/>
...
<!-- START extra files needed for
non-Jboss appservers -->
<fileset dir="build/jbpm.sar.dir"
includes="*.jar"/>
<fileset dir="lib/hibernate"
includes="hibernate3.jar"/>
<fileset dir="lib/jboss"
includes="cglib-2.1_2jboss.jar, commons-collections.jar, log4j.jar,
antlr-2.7.5H3.jar, asm-attrs.jar, asm.jar, commons-logging.jar,
jboss-common.jar, bsh-1.3.0.jar, xercesImpl.jar, xml-apis.jar"/>
<!-- END extra files needed for
non-Jboss appservers -->
...
</target> <!-- ================= -->
<!-- TASKS FOR DERBY -->
<!-- ================= -->
<target name="create.db.derby" depends="declare.jbpm.tasks"
description="creates a derby database with the jbpm
tables and loads the processes in there. Run this target after
starting derby">
<jbpmschema actions="create"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/derby/create.db.hibernate.properties"/>
<loadidentities
file="${basedir}/src/resources/derby/identity.db.xml"
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/derby/create.db.hibernate.properties"/>
<ant antfile="build.xml" target="build.processes"
inheritall="false" />
<deployprocess
cfg="${basedir}/src/config.files/hibernate.cfg.xml"
properties="${basedir}/src/resources/derby/create.db.hibernate.properties">
<fileset dir="build"
includes="*.process" />
</deployprocess>
</target>
<property
file="${basedir}/src/resources/derby/create.db.hibernate.properties"/>
<target name="execute.derby.sql" description="execute a derby
sql script with -Dderby.script=path-to-script.">
<sql driver="${hibernate.connection.driver_class}"
url="${hibernate.connection.url}"
userid="${hibernate.connection.username}"
password="${hibernate.connection.password}"
delimiter=";"
autocommit="true"
onerror="continue" >
<classpath refid="classpath.ant"/>
<transaction src="${derby.script}"/>
</sql>
</target>
cd $JBPM_HOME
ant build
ant -f build.deploy.xml build.webapp
Relevant files have been copied to
$JBPM_HOME/build/jbpm.war.dir, and
jarred up into a war file $JBPM_HOME/build/jbpm.war.
Start Derby with either asadmin
command or Derby scriptsIf you use Derby scripts, make sure JAVA_HOME
and DERBY_INSTALL environment variable have been set, for
example, to /file/jdk504, and $SJSAS_HOME/derby, respectively.
$SJSAS_HOME/bin/asadmin start-database; OR
cd $SJSAS_HOME/derby/frameworks/NetworkServer/bin; ksh
startNetworkServer.ksh
To shutdown Derby with asadmin stop-database, or stopNetworkServer.ksh.
Generate schemas and populate
tables with create.db.derby target
cd $JBPM_HOME
ant -f build.deploy.xml create.db.derby/starters-kit/jbpm-db/build/derby/derby.create.sql,
derby.drop.sql, derby.clean.sql, derby.drop.create.sql/file/as82/derby/frameworks/NetworkServer/bin > ksh ij.ksh
ij version 10.1
ij> connect
'jdbc:derby://localhost:1527/sun-appserv-samples;create=true;user=APP;password=APP';
ij> select NAME_ from JBPM_ID_USER;
NAME_
---------------------------------------
cookie
monster
ernie
bert
grover
4 rows selectedij> quit;
If JBPM_ID_USER table has not been populated, you can do it with
execute.derby.sql target. First, create a derby.insert.sql file
based on this.
Note that you need to remove the single quote around the ID_ value,
e.g., '1', '2'.$SJSAS_HOME/bin/asadmin deploy $JBPM_HOME/build/jbpm.war,
or you can just use autodeploy by copying the war to $SJSAS_HOME/domains/domain1/autodeploytechnorati tags: jbpm, glassfish, sjsas, derby, myfaces
Posted at 12:58PM Mar 22, 2006 by chengfang in Glassfish | Comments[10]