I am using JBPM 5.3 with Jboss 7.1 and Seam managed persistence context here is my persistence.xml
<persistence 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"
version="2.0">
<persistence-unit name="main" transaction-type="JTA">
<description>Forge Persistence Unit</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/oracleDS</jta-data-source>
<mapping-file>META-INF/JBPMOrm-JPA2.xml</mapping-file>
<mapping-file>META-INF/Taskorm.xml</mapping-file>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.jbpm.task.Attachment</class>
<class>org.jbpm.task.Content</class>
<class>org.jbpm.task.BooleanExpression</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Delegation</class>
<class>org.jbpm.task.Escalation</class>
<class>org.jbpm.task.Group</class>
<class>org.jbpm.task.I18NText</class>
<class>org.jbpm.task.Notification</class>
<class>org.jbpm.task.EmailNotification</class>
<class>org.jbpm.task.EmailNotificationHeader</class>
<class>org.jbpm.task.PeopleAssignments</class>
<class>org.jbpm.task.Reassignment</class>
<class>org.jbpm.task.Status</class>
<class>org.jbpm.task.Task</class>
<class>org.jbpm.task.TaskData</class>
<class>org.jbpm.task.SubTasksStrategy</class>
<class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
<class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
<class>org.jbpm.task.User</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<!-- <class>org.jbpm.process.audit.ProcessInstanceLog</class> <class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class> -->
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.transaction.flush_before_completion"
value="true" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!--
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
-->
</properties>
</persistence-unit>
</persistence>
here is the code -
@Resource( mappedName = "java:/TransactionManager" )
private TransactionManager tm;
@Inject
private UserTransaction ut;
public void startProcess() {
try {
// getUserTransaction().begin();
new TaskManagerServer().startServer();
KnowledgeBase kbase = readKnowledgeBase();
TransactionManager manager = (TransactionManager) new InitialContext().lookup( "java:jboss/TransactionManager" );
//manager.begin();
// create the entity manager factory and register it in the environment
EntityManagerFactory emf = EMFactory.getEntityManagerFactory(); // Persistence.createEntityManagerFactory( "main" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
env.set( EnvironmentName.TRANSACTION, ut );
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>();
params.put( "name", "Arthur" );
params.put( "money", 800 );
// create a new knowledge session that uses JPA to store the runtime state
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
AsyncMinaHTWorkItemHandler handler = new AsyncMinaHTWorkItemHandler( ksession );
// CommandBasedWSHumanTaskHandler handler = new CommandBasedWSHumanTaskHandler( ksession );
ksession.getWorkItemManager().registerWorkItemHandler( "Human Task", handler );
String name = "ksclient-" + UUID.randomUUID();
// invoke methods on your method here
ksession.startProcess( "process_1", params );
TaskClient client = new TaskClient( new MinaTaskClientConnector( name, new MinaTaskClientHandler(
SystemEventListenerFactory.getSystemEventListener() ) ) );
client.connect( "127.0.0.1", 9123 );
BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
client.getTasksAssignedAsPotentialOwner( "john", "en-US", taskSummaryResponseHandler ); // this line throws but continues
List<TaskSummary> tasks = taskSummaryResponseHandler.getResults(); // number of tasks is always zero
for ( TaskSummary taskSummary : tasks ) {
System.out.println( taskSummary.getName() );
}
//manager.commit();
// getUserTransaction().commit();
// ksession.dispose();
} catch ( Throwable t ) {
t.printStackTrace();
}
}
405 ERROR [org.jbpm.task.service.TaskServerHandler] (NioProcessor-1) Could not start transaction.: java.lang.RuntimeException: Could not start transaction.
at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:994) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
at org.jbpm.task.service.TaskServiceSession.addTask(TaskServiceSession.java:186) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
at org.jbpm.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:144) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
at org.jbpm.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41) [jbpm-human-task-mina-5.3.0.Final.jar:5.3.0.Final]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:176) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969) [mina-core-2.0.0-RC1.jar:]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.0-RC1.jar:]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_31]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
Caused by: java.lang.NullPointerException
at org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:205) [drools-persistence-jpa-5.4.0.Final.jar:5.4.0.Final]
at org.jbpm.task.service.persistence.TaskJTATransactionManager.getStatus(TaskJTATransactionManager.java:63) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
at org.jbpm.task.service.persistence.TaskJTATransactionManager.begin(TaskJTATransactionManager.java:36) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
at org.jbpm.task.service.persistence.TaskPersistenceManager.beginTransaction(TaskPersistenceManager.java:79) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:976) [jbpm-human-task-core-5.3.0.Final.jar:5.3.0.Final]
... 28 more