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

2010-03-25 Thread Nol de Wit
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
providerorg.hibernate.ejb.HibernatePersistence/provider
jta-data-sourcejdbc/processInstanceDS/jta-data-source
classorg.drools.persistence.session.SessionInfo/class
classorg.drools.persistence.processinstance.ProcessInstanceInfo/class

classorg.drools.persistence.processinstance.ProcessInstanceEventInfo/class
classorg.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();


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

2010-03-25 Thread Nol de Wit
I got a bit further on this: it appears that for 5.1 there are a couple of
extra mapped classes:

classorg.drools.persistence.processinstance.variabletypes.VariableInstanceInfo/class
classorg.drools.persistence.processinstance.variabletypes.JPAPersistedVariable/class

This got me much further, but no success yet: the tables are created in the
database, but apparently at the point some data is inserted an error occurs,
see below.
I've updated BTM to 1.3.3, but that didn't help.

Any ideas?
Thanks,
Nol

Mar 25, 2010 11:00:33 PM bitronix.tm.journal.DiskJournal open
WARNING: active log file is unclean, previous server crash ?
Mar 25, 2010 11:00:33 PM bitronix.tm.recovery.Recoverer run
INFO: recovery committed 0 dangling transaction(s) and rolled back 0 aborted
transaction(s) on 1 resource(s) [jdbc/processInstanceDS] (restricted to
serverId '192.168.178.32')
line 2:47 mismatched character 'EOF' expecting '\n'
Hibernate: insert into SessionInfo (dirty, lastModificationDate,
rulesByteArray, startDate) values (?, ?, ?, ?)
Mar 25, 2010 11:00:35 PM bitronix.tm.BitronixTransaction
fireAfterCompletionEvent
WARNING: Synchronization.afterCompletion() call failed for a
DeferredReleaseSynchronization of a JdbcPooledConnection from datasource
jdbc/processInstanceDS in state NOT_ACCESSIBLE wrapping
com.mysql.jdbc.jdbc2.optional.jdbc4mysqlxaconnect...@1d3c66d8
java.lang.IllegalArgumentException: null source
at java.util.EventObject.init(EventObject.java:38)
at javax.sql.StatementEvent.init(StatementEvent.java:39)
at
com.mysql.jdbc.jdbc2.optional.JDBC4PreparedStatementWrapper.close(JDBC4PreparedStatementWrapper.java:70)
at
bitronix.tm.resource.jdbc.JdbcPooledConnection.stateChanging(JdbcPooledConnection.java:205)
at
bitronix.tm.resource.common.AbstractXAStatefulHolder.fireStateChanging(AbstractXAStatefulHolder.java:61)
at
bitronix.tm.resource.common.AbstractXAStatefulHolder.setState(AbstractXAStatefulHolder.java:30)
at
bitronix.tm.resource.common.DeferredReleaseSynchronization.afterCompletion(DeferredReleaseSynchronization.java:33)
at
bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:416)
at
bitronix.tm.BitronixTransaction.rollback(BitronixTransaction.java:227)
at
bitronix.tm.BitronixTransactionManager.rollback(BitronixTransactionManager.java:104)
at
org.drools.persistence.session.SingleSessionCommandService.init(SingleSessionCommandService.java:128)
at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
at
pilot.tests.DroolFlowPersistenceTest.main(DroolFlowPersistenceTest.java:60)
java.lang.RuntimeException: Could not commit session
at
org.drools.persistence.session.SingleSessionCommandService.init(SingleSessionCommandService.java:133)
at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
at
pilot.tests.DroolFlowPersistenceTest.main(DroolFlowPersistenceTest.java:60)
Caused by: java.lang.IllegalArgumentException: null source
at java.util.EventObject.init(EventObject.java:38)
at javax.sql.StatementEvent.init(StatementEvent.java:39)
at
com.mysql.jdbc.jdbc2.optional.JDBC4PreparedStatementWrapper.close(JDBC4PreparedStatementWrapper.java:70)
at
org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:563)
at
org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
at
org.hibernate.id.insert.AbstractReturningDelegate.releaseStatement(AbstractReturningDelegate.java:82)
at
org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:60)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2186)
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2666)
at
org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at
org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at
org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)