[rules-users] Persitence configuration issue in Drools Flow 5.1.M1 (PersistenceException/AnnotationException)

Nol de Wit noldewit at gmail.com
Thu Mar 25 12:47:05 EDT 2010


Hi,

(using Droolw Flow 5.1.M1)

I've made a reasonably simple Drool Flow model, containing a ForEach,
a split and  and a couple of actions. Without Persistence it works
nicely: I start it with one variable/parameter, a class I call Report
with 4 Lines of data . Each of the lines get's worked on correctly in
the ForEach.

Next I want to add Persistence to the model; I made a persistence.xml,
which is based on the one as shown in chapter 5 of the online Drools
Flow documentation. See below.

I changed the H2 db to a mysql DB.

The firs call (after creating the datasource) in my test now gives an
exception. See the call and exception below.

1) what's wrong? I think my persistence.xml is correct. So what is the
error trying to tell me? Is saying that I should map my parameters
data (Report and Line)? I just read an article from salaboy about
variable persistence 5.1, but I'm not using that...

2) What puzzles me is the link between the persistence.xml (containing
mapping info), and the datasource (containing the credentials of the
DB). In the doc and PerformanceTest.java class in the examples I don't
see any link. Is creating the DataSource enough to get it in JNDI?

Thanks,
Nol


Some of my code and config:

// See makeDataSource() below
PoolingDataSource ds = makeDataSource();

// this call gives an exception:
EntityManagerFactory emf =
	Persistence.createEntityManagerFactory( "nl.dnb.avb.drools.jpa" );


25-mrt-2010 14:30:00 org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class:
org.drools.persistence.processinstance.WorkItemInfo
25-mrt-2010 14:30:00 org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity org.drools.persistence.processinstance.WorkItemInfo
on table WorkItemInfo
javax.persistence.PersistenceException: [PersistenceUnit:
nl.dnb.avb.drools.jpa] Unable to configure EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
	at pilot.tests.DroolFlowPersistenceTest.main(DroolFlowPersistenceTest.java:41)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or
@ManyToMany targeting an unmapped class:
org.drools.persistence.processinstance.ProcessInstanceInfo.variables[org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo]
	at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1071)
	at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602)
	at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:79)


Persistence.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
  version="1.0"
  xsi:schemaLocation=
    "http://java.sun.com/xml/ns/persistence
     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
     http://java.sun.com/xml/ns/persistence/orm
     http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/persistence">

  <persistence-unit name="nl.dnb.avb.drools.jpa">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/processInstanceDS</jta-data-source>
    <class>org.drools.persistence.session.SessionInfo</class>
    <class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
    <class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
    <class>org.drools.persistence.processinstance.WorkItemInfo</class>

    <properties>
      <!--  property name="hibernate.dialect"
value="org.hibernate.dialect.H2Dialect"/ -->
      <property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.max_fetch_depth" value="3"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.transaction.manager_lookup_class"
                value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
    </properties>
  </persistence-unit>
</persistence>



	private static PoolingDataSource makeDataSource() {
		
		PoolingDataSource ds = new PoolingDataSource();
		ds.setUniqueName("jdbc/processInstanceDS");
		ds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
		ds.setMaxPoolSize(3);
		ds.setAllowLocalTransactions(true);
		ds.getDriverProperties().put("user", "drools");
		ds.getDriverProperties().put("password", "drools");
		ds.getDriverProperties().put("URL", "jdbc:mysql://DNB35362:3306/drools");
		ds.init();
		
		return ds;
		
	}



More information about the rules-users mailing list