从审核日志获取Process Instance Variables时,出现以下错误:
Caused by: java.lang.IllegalStateException: Unable to find JTA transaction.
at org.jbpm.process.audit.strategy.StandaloneJtaStrategy.joinTransaction(StandaloneJtaStrategy.java:45) [jbpm-audit.jar:6.2.0.Final]
at org.jbpm.process.audit.JPAAuditLogService.joinTransaction(JPAAuditLogService.java:370) [jbpm-audit.jar:6.2.0.Final]
at org.jbpm.process.audit.JPAAuditLogService.executeQuery(JPAAuditLogService.java:378) [jbpm-audit.jar:6.2.0.Final]
at org.jbpm.process.audit.JPAAuditLogService.findVariableInstances(JPAAuditLogService.java:275) [jbpm-audit.jar:6.2.0.Final]
at za.co.symbiotics.jbpm.runtime.ProcessManager.getProcessInstanceVariables(ProcessManager.java:53) [process-service-ejb.jar:]
任何帮助将不胜感激。根据上一个问题,我已经验证了persistence.xml中的transaction-type="JTA"
代码段:
List<?> variableList = processFactory.getAuditService().findVariableInstances(processInstanceId);
public AuditService getAuditService() {
RuntimeEngine runtime = runtimeManager.getRuntimeEngine(EmptyContext.get());
return runtime.getAuditService();
}
Persistence.xml:
<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/jbpm-ds</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<mapping-file>META-INF/Taskorm.xml</mapping-file>
<mapping-file>META-INF/TaskAuditorm.xml</mapping-file>
<mapping-file>META-INF/Servicesorm.xml</mapping-file>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.jbpm.persistence.correlation.CorrelationKeyInfo</class>
<class>org.jbpm.persistence.correlation.CorrelationPropertyInfo</class>
<class>org.jbpm.process.audit.ProcessInstanceLog</class>
<class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class>
<class>org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo</class>
<class>org.jbpm.services.task.impl.model.AttachmentImpl</class>
<class>org.jbpm.services.task.impl.model.ContentImpl</class>
<class>org.jbpm.services.task.impl.model.BooleanExpressionImpl</class>
<class>org.jbpm.services.task.impl.model.CommentImpl</class>
<class>org.jbpm.services.task.impl.model.DeadlineImpl</class>
<class>org.jbpm.services.task.impl.model.DelegationImpl</class>
<class>org.jbpm.services.task.impl.model.EscalationImpl</class>
<class>org.jbpm.services.task.impl.model.GroupImpl</class>
<class>org.jbpm.services.task.impl.model.I18NTextImpl</class>
<class>org.jbpm.services.task.impl.model.NotificationImpl</class>
<class>org.jbpm.services.task.impl.model.EmailNotificationImpl</class>
<class>org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl</class>
<class>org.jbpm.services.task.impl.model.PeopleAssignmentsImpl</class>
<class>org.jbpm.services.task.impl.model.ReassignmentImpl</class>
<class>org.jbpm.services.task.impl.model.TaskImpl</class>
<class>org.jbpm.services.task.impl.model.TaskDataImpl</class>
<class>org.jbpm.services.task.impl.model.UserImpl</class>
<class>org.jbpm.services.task.audit.impl.model.AuditTaskImpl</class>
<class>org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl</class>
<class>org.jbpm.services.task.audit.impl.model.TaskEventImpl</class>
<class>org.jbpm.kie.services.impl.store.DeploymentStoreEntry</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.id.new_generator_mappings" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
Wildfly 8.2.0数据源定义:
<datasource jta="true" jndi-name="java:jboss/datasources/jbpm-ds" pool-name="bpm-ds" enabled="true" use-java-context="true" use-ccm="false">
<connection-url>jdbc:postgresql://localhost:5432/bpm</connection-url>
<driver>postgresql</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>userId</user-name>
<password>password</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<background-validation-millis>1</background-validation-millis>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>