How to run Activiti in Glassfish/Postgresql in JTA mode

What you need:
1.) Glassfish

2.) Postgresql - make sure that max_transactions is set to at least 10. Otherwise you will encounter the no session error because by default the value is 0.

3.) Checkout travelexpenses from:

4.) Modify the following files as follows:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
 xmlns="" xmlns:xsi=""

 <persistence-unit name="activitiPU">
  <!-- If you are running in a production environment, add a managed data 
   source, the example data source is just for proofs of concept! -->


   <!-- Properties for Hibernate -->
   <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
   <property name="hibernate.connection.<" value="org.postgresql.Driver" />
   <property name="" value="update" />
   <property name="connection.autocommit" value="true" />
   <property name="hibernate.show_sql" value="false" />
   <property name="hibernate.format_sql" value="false" />

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

 <!-- activiti configuration for glassfish application server -->

 <!-- lookup the JTA-Transaction manager -->
 <bean id="transactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName" value="java:appserver/TransactionManager"></property>
  <property name="resourceRef" value="true" />

 <!-- process engine configuration -->
 <bean id="processEngineConfiguration" class="org.activiti.cdi.CdiJtaProcessEngineConfiguration">
  <property name="dataSourceJndiName" value="activitiDS" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="transactionsExternallyManaged" value="true" />
  <property name="databaseSchemaUpdate" value="true" />

5.) Make sure that you have successfully define the following inside Glassfish:
Connection Pools
Pool JDBC Connection

6.) Since we have 2 PersistenceContext, in AuthenticationBean make sure that you specify unitName when injecting entity manager:

@PersistenceContext(unitName = "activitiPU")
private EntityManager entityManager;
How to run Activiti in Glassfish/Postgresql in JTA mode How to run Activiti in Glassfish/Postgresql in JTA mode Reviewed by Edward Legaspi on Saturday, December 01, 2012 Rating: 5

No comments:

Powered by Blogger.