Brian Wallis [
https://community.jboss.org/people/bwallis42] created the discussion
"Re: jbpm 5.3 - kSession.dispose() - Error: Session was previously disposed"
To view the discussion, visit:
https://community.jboss.org/message/748137#748137
--------------------------------------------------------------
I have the same problem where I am getting a session from within an onMessage() method of
an Message Driven Bean. The transactions are container controlled so I cannot call the
ksession dispose after the transaction ends since the container ends the transaction not
me.
This was working with JBPM 5.1.
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
public void onMessage(Message message)
{
try
{
DocumentCreated inbound = MessageBusUtility.unmarshallMessage(message);
LOGGER.info("Message body: " + inbound);
ksession = jbpmLauncher.getSession();
// start a new process instance
Map<String, Object> params = buildParams(inbound);
ksession.startProcess("au.com.infomedix.harvey." +
inbound.getDocumentGroup().getWorkflowName().toLowerCase(), params);
Audit.newWorkflow((String) params.get(EReferralFields.PATIENT_URNO.getKey()),
(String) params.get(EReferralFields.PATIENT_DOMAIN.getKey()),
(String) params.get(EReferralFields.PATIENT_FIRSTNAME.getKey()),
(String) params.get(EReferralFields.PATIENT_LASTNAME.getKey()));
ksession.fireAllRules();
// TODO This should be disposed but this fails within the transaction
boundary.
// ksession.dispose(); //dispose after use.
}
catch (Exception e)
{
throw new RuntimeException("Exception occurred.", e);
}
}
where the getSession method is
public StatefulKnowledgeSession getSession(int sessionId)
{
initialize();
StatefulKnowledgeSession ksession =
JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, kconfig,
kenvironment);
registerWorkItemHandlers(ksession);
return ksession;
}
Not sure how to proceed with this. Seems I need to get the container to dispose of the
session after the transaction but that isn't possible with an MDB as far as I know.
thanks.
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/748137#748137]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]