Deal of the Day

Home » Main » Manning Forums » 2010 » Activiti in Action

Thread: JPA with Activiti configs files

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Pages: 1 - Last Post: Apr 14, 2012 9:21 AM by: psagarna
psagarna

Posts: 11
From: UK
Registered: 3/28/12
JPA with Activiti configs files
Posted: Apr 14, 2012 8:29 AM
  Click to reply to this thread Reply

Hi all,

IŽ becaming be crazy with the config JPA in activiti. I will apreaciate any observation from you becouse I can not see the problem becouse the same config with a webapp works fine.

I have the next configs:

persistence.xml inside activiti-explorer/META-INF contains:
<?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="testJPA" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>com.pizza.Book</class>
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost/jpatest"/>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionUserName" value="root"/>
<property name="openjpa.ConnectionPassword" value=""/>
<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
</properties>
</persistence-unit>
</persistence>

2) applicationContext.xml keep the instalation default and this part only add few lines:

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="databaseType" value="h2" />
<property name="dataSource" ref="dataSource" />
<property name="databaseSchemaUpdate" value="true" />
<!--property name="transactionManager" ref="transactionManager" /-->
<property name="jobExecutorActivate" value="false" />
<property name="transactionManager" ref="transactionManager" />
<property name="jpaPersistenceUnitName" value="testJPA" />
<property name="jpaHandleTransaction" value="true" />
<property name="jpaCloseEntityManager" value="true" />

<property name="customFormTypes">
<list>
<ref bean="userFormType"/>
</list>
</property>
</bean>

<bean id="order" class="com.pizza.OrderService" />
<bean id="book" class="com.pizza.BookService" />

3) BookService which is calling from one serviceActiviti and is working fine the call but fails the part of JPA particulary entityManagerFactory>

public Book createBook(DelegateExecution execution) {

Book pablo= new Book();
pablo.setTitulo(""+execution.getVariable("titulo"));
pablo.setIsbn(""+execution.getVariable("isbnLibro"));

EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("testJPA");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(pablo);
em.getTransaction().commit();

Query q = em.createQuery("SELECT c FROM Book c");
List<Book> companias = q.getResultList();
Iterator<Book> iterator=companias.iterator();
while (iterator.hasNext()) {
Book pablo2 = (Book) iterator.next();
System.out.println(pablo2.getTitulo());
}
return pablo;
}

4)openjpa-2.2.0.jar and mysql*jar all of them are in activiti-explorer/WEB-INF/lib

4) After this the exception is
Caused by: org.activiti.engine.impl.javax.el.ELException: <openjpa-2.2.0-r422266
:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: A J
DBC Driver or DataSource class name must be specified in the ConnectionDriverNam
e property. Available properties in configuration are "org.apache.openjpa.jdbc.c
onf.JDBCConfigurationImpl@442ce698".


Many thanks,

Cheers,

Pablo.

tijs.rademakers

Posts: 494
From: Netherlands
Registered: 6/6/06
Re: JPA with Activiti configs files
Posted: Apr 14, 2012 8:43 AM   in response to: psagarna in response to: psagarna
  Click to reply to this thread Reply

Hi,

This looks like a OpenJPA issue to me. Are you sure the persistence.xml configuration is correct for OpenJPA?

Best regards,

Tijs

psagarna

Posts: 11
From: UK
Registered: 3/28/12
Re: JPA with Activiti configs files
Posted: Apr 14, 2012 9:21 AM   in response to: tijs.rademakers in response to: tijs.rademakers
  Click to reply to this thread Reply

Hi Tijs,

Yes, I have try the same config file with webproject and works. But I think there are something wrong in the processEngineConfiguration is that posible? Are ok these lines:
<property name="jpaPersistenceUnitName" value="testJPA" />
<property name="jpaHandleTransaction" value="true" />
<property name="jpaCloseEntityManager" value="true" />

Also, I have tried to run the same project (which are in section 6.3.3) outside eclipse and junit test (becouse runs with junits test) in activiti tomcat but it is not running, other exceptions happends. I guessing some problems with applicationContext is that posible?

Many thanks,

regards,

Cheers,

Pablo

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor