views:

595

answers:

1

I'm trying to follow the Drools Flow example code in the Human Task documentation and I have the following code:

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.drools.task.service.TaskService;

// ...

EntityManagerFactory emf = 
  Persistence.createEntityManagerFactory("org.drools.task");
TaskService taskService = new TaskService(emf, null);

I have put a persistence.xml file in META-INF as specified here (which is definitely getting picked up as I get an XML parsing error if I mangle it) but the following exception is thrown:

Exception in thread "main" java.lang.IllegalArgumentException: 
  Named query not found: UnescalatedDeadlines
at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(
  AbstractEntityManagerImpl.java:108)
at org.drools.task.service.TaskService.<init>(TaskService.java:65)
at org.drools.task.service.TaskService.<init>(TaskService.java:48)
at com.sample.RuleFlowTest.main(RuleFlowTest.java:32)`

Note that the second parameter to TaskService is required but not mentioned in the documentation. It seems unlikely to me but could it be that setting it to null as I've done is causing this issue?

A: 

I prevented this exception by copying both persistence.xml and orm.xml from drools-process-task-5.0.1.jar/META-INF (the UnescalatedDeadlines named query being specified in orm.xml) into my built META-INF directory.

However, I'm now getting another exception (java.lang.NoClassDefFoundError: antlr/ANTLRException from Hibernate)...

To fix the antlr/ANTLRException problem I downloaded the latest Hibernate distribution (hibernate-distribution-3.3.2.GA-dist.zip) and added antlr-2.7.6.jar from the lib directory to the classpath.

Does it need to be this complicated?

Matthew Murdoch