5.5. Enterprise archive

In the deploy directory of the downloads, you can find jbpm-enterprise.ear. That J2EE 1.4 compliant enterprise archive includes: jPDL libraries, jBPM configuration files, the jBPM web console, and a couple of enterprise beans. In this package, jBPM is configured for usage in an application server like e.g. JBoss. Asynchronous messaging service is here bound to JMS and the scheduler service is bound to the EJB Timer Service. So here in this .ear file, there is no JobExecutor started. Also the hibernate session that jBPM uses is configured to participate in the overall JTA transaction.

Within jbpm-enterprise.ear there are the following files:

jbpm-console.war - the jbpm console web application

jbpm-enterprise.jar - several jBPM EJB compnents

lib/jbpm-configs.jar - jBPM configuration files

lib/jbpm-identity.jar - jBPM identity component classes

lib/jbpm-jpdl.jar - jBPM jpdl classes

meta-inf/application.xml

jbpm-enterprise.jar contains the following EJB components:

CommandListenerBean - a Message Driven Bean that listens on the jbpmCommandQueue for jBPM command messages.

CommandServiceBean - a Stateless Session Bean that executes jBPM Commands.

JobListenerBean - a Message Driven Bean that listeners on the jbpmJobQueue for jBPM job messages to support asynchronous continuations.

TimerServiceBean - a TimerBean that implements the jBPM timer service.

These beans are J2EE 1.4 / EJB 2.1 compliant, to allow them to be deployed on a variety of application servers. Note however that jBPM only provide deployment descriptors for JBoss Application Servers. All beans are deployed without specifying transaction-attribure, therefore by default they have transaction-attribure "Required".

The CommandListenerBean delegates Command execution to the CommandServiceBean, which in turn delegates to a CommandServiceImpl class that executes the command class by calling it's execute method.

The source for these classes is in: ?????????????????????

Also, the jbpm-enterprise-jar includes and ear directory with a second copy of application.xml. Why is this here ??????????????????

jbpm-enterprise.jar also contains JmsMessageServiceFactoryImpl, which is responsible for sending Jobs as JMS messages to support asynchronous continuations.

jbpm-configs.jar contains the following files:

hibernate.cfg.xml
jbpm.cfg.xml
jbpm.mail.templates.xml

hibernate.cfg.xml includes the following configuration items that may require modification to support other databases or application servers.

  <!-- hibernate dialect -->
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>

    <!-- JDBC connection properties (begin) ===
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:mem:jbpm</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password"></property>
    ==== JDBC connection properties (end) -->
    
    <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
    
    <!-- JBoss transaction manager lookup (begin) -->
    <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
    <!-- JBoss transaction manager lookup (end) -->

    <!-- DataSource properties (begin) -->
    <property name="hibernate.connection.datasource">java:/JbpmDS</property>
    <!-- DataSource properties (end) -->
    
    <!-- JTA transaction properties (begin) ===
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
    <property name="jta.UserTransaction">java:comp/UserTransaction</property>
    ==== JTA transaction properties (end) -->

    <!-- CMT transaction properties (begin) -->
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
    <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
    <!-- CMT transaction properties (end) -->

    <!-- logging properties (begin) ===
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.format_sql">true</property>
    <property name="hibernate.use_sql_comments">true</property>
    ==== logging properties (end) -->

You may replace the hibernate.dialect with one that corresponds to your database management system.

You may replace the HashtableCacheProvider with other Hibernate supported cache providers, such as EhCache.

The transaction.manager.lookup may be replace with values appropirate to other applications servers, e.g. WebSphereTransactionManagerLookup ro WebLogicTransactionManagerLookup when deploying to those application servers.

Similarly, if deploying on another application server you must change the name of the hibernate.connection.datasource to the jndi name of the datasource on that application server..

Out-of-the-box jBPM is configured to use CMTTransactionFactory.CMTTransactionFactory always assumes that the container has started a JTA transaction. This will be true if you use the jBPM CommandListener or CommandService beans, or your own EJBs that use container managed transaction. If this is not always the case, then change this configuration to use the JTATransactionFactory. When JTATransactionFactory is configured, Hibenate will use the JTA transaction if it already exists, but will start a JTA transaction if it does not.

jbpm.cfg.xml included the following configuration items:

 <jbpm-context>
    <service name="persistence">
      <factory>
        <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
          <field name="isCurrentSessionEnabled"><true /></field>
          <field name="isTransactionEnabled"><false /></field>
        </bean>
      </factory>
    </service>
    <service name="message">
      <factory>
        <bean class="org.jbpm.msg.jms.JmsMessageServiceFactoryImpl">
          <field name="connectionFactoryJndiName"><string value="java:/JmsXA"/></field>
          <field name="destinationJndiName"><string value="queue/JbpmJobQueue"/></field>
        </bean>
      </factory>
    </service>
    <service name="scheduler" factory="org.jbpm.scheduler.ejbtimer.EjbSchedulerServiceFactory" />

isCurrentSessionEnabled true means jBPM will request Hibernate to use the current session associated with the current transaction. If there is no current transaction, an exception will be thrown stating no session is active. In this case, you may want to set this isCurrentSessionEnabled to false, and inject the current session into the JbpmContext via the JbpmContext.setSession(session) method. This will also insure that jBPM uses the same Hibernate session as other parts of your application. Note, the Hibenrate session can be injected into a stateless session bean via a persistence context, for example.

isTransactionEnabled true means jBPM will begin Hibernate transaction upon JbpmConfiguraiton().createJbpmContext and commit Hibernate transactions and close Hibernate sessions upon jbpmContext.close()..This is NOT the desired behaviour when jBPM is deployed as an ear, hence the value of isTransactionEnabled is set to false by default in this configuration.

Transaction Management