How to run Activiti in Glassfish/Postgresql in JTA mode
Tech-Today

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:
https://svn.camunda.com/fox/demo/activiti-cdi/travelexpenses/trunk/

4.) Modify the following files as follows:
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

<persistence-unit name="activitiPU">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- If you are running in a production environment, add a managed data
source, the example data source is just for proofs of concept! -->
<jta-data-source>activitiDemoDS</jta-data-source>

<class>com.camunda.fox.activiti.cdi.example.travelexpenses.domain.Employee</class>

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

activiti.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


<!-- 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" />
</bean>

<!-- 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" />
</bean>
</beans>

5.) Make sure that you have successfully define the following inside Glassfish:
Connection Pools
-activitiPool
-activitiDemo
Pool JDBC Connection
-activitiDS
-activitiDemoDS

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

@PersistenceContext(unitName = "activitiPU")
private EntityManager entityManager;




- Wildfly Server Provisioning Elastic Search Integration
I'm interested and would like to evaluate the integration of Elasticsearch to hibernate-search. I'm using the Wildfly container, however, Wildfly's hibernate-search library is a bit outdated: 5.5.8. so I need to find a way to outdate the jars...

- Hibernate With Infinispan Tutorial For Beginners
This tutorial is for developers who are just beginning to learn hibernate-search and trying to set up a demo project. Most of the codes are copied from the hibernate-search documentation: https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/...

- How To Auto Wire A Spring Bean From A Jsf Managed Bean In Liferay Portlet
There are 2 ways I know to auto-wire a spring bean into a jsf managed bean: 1.) Is through WebApplicationContext, invoke during jsf managed bean constructor: Below are the most vital files to perform this action: web.xml <?xml version="1.0"?>...

- Changing Jboss Server's Default Http Port
If you have installed jboss server in: C:\jboss-5.1.0\ then here's what you should do to change the default port (8080) to any port of your choice. 1.) Open the file, C:\jboss-5.1.0\server\default\conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml...

- How To Get Started With Hibernate In Java. Create A Simple Class And Database Schema For Demostration.
Since, I've always been using different database sometimes I get confused how to implement the others. Like hibernate, where the configuration must be properly set. *This help assumes that you have already created a java project in eclipse that has...



Tech-Today








.