Hi all , we are using JBPM 5.3 on Jboss 7.1 with Hibernate 4 and using JBoss's transaciton manager and seam managed persistence context, when I try to start a process I get the following error
08:53:14,876 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) SQL Error: 23502, SQLState: 23502
08:53:14,878 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) NULL not allowed for column "INSTANCEID"; SQL statement:
insert into ProcessInstanceInfo (InstanceId, id, lastModificationDate, lastReadDate, processId, processInstanceByteArray, startDate, state, OPTLOCK) values (null, ?, ?, ?, ?, ?, ?, ?, ?) [23502-161]
08:53:14,888 ERROR [org.drools.persistence.SingleSessionCommandService] (http-localhost-127.0.0.1-8080-1) Could not commit session:
: org.hibernate.exception.ConstraintViolationException
public void
startProcess() {
try
{
KnowledgeBase kbase = readKnowledgeBase();
TransactionManager manager = (TransactionManager) new InitialContext().lookup("java:jboss/TransactionManager"
);
// create the entity manager factory and register it in the environment
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "main"
);
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY
, emf );
//env.set( EnvironmentName.TRANSACTION, getUserTransaction());
env.set(EnvironmentName.GLOBALS, new
MapGlobalResolver());
env.set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER, entityManager
);
env.set(EnvironmentName.TRANSACTION_MANAGER
, manager);
Map<String, Object> params = new
HashMap<String, Object>();
// org.drools.persistence.info.WorkItemInfo wi;
//org.jbpm.task.Comment comment;
params.put("name", "Arthur"
);
params.put("money"
, 1800);
// create a new knowledge session that uses JPA to store the runtime state
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null
, env );
int
sessionId = ksession.getId();
System.out
.println(sessionId);
// invoke methods on your method here
ksession.startProcess( "process_1"
, params);
ksession.dispose();
} catch
( Throwable t ) {
t.printStackTrace();
}
Here is my persistence.xml
<
persistence xmlns=
"http://java.sun.com/xml/ns/persistence"