Bug 868873

Summary: Exception is thrown when disposing JPA knowledge session on JBoss EAP 5.1
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Radovan Synek <rsynek>
Component: BRE (Expert, Fusion)Assignee: Kris Verlaenen <kverlaen>
Status: CLOSED NOTABUG QA Contact: Radovan Synek <rsynek>
Severity: high Docs Contact:
Priority: unspecified    
Version: BRMS 5.3.1CC: brms-jira, kverlaen, lpetrovi, mrietvel, rrajasek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-10-24 06:52:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
server log
none
reproducer: maven ear project
none
DS configuration for Oracle11g none

Description Radovan Synek 2012-10-22 10:45:09 UTC
Created attachment 631397 [details]
server log

Description of problem:
Exception saying that "This session was previously disposed." is thrown when trying to dispose JPA knowledge session after successfull jbpm process completion.

scenario:
process instance launched from EJB with CMT (I tried BMT too - with the same exception at result)

See the attached server log for more detailed information.

Version-Release number of selected component (if applicable):
5.3.1.BRMS-ER3

Steps to Reproduce:
1. deploy the reproducer on JBoss EAP/AS 
2. access URL: http://localhost:8080/process/run
3. search the server log for the error stacktrace
  
The reproducer will be attached soon.

Comment 1 Radovan Synek 2012-10-22 11:17:47 UTC
Created attachment 631406 [details]
reproducer: maven ear project

Comment 2 Radovan Synek 2012-10-22 11:19:00 UTC
Created attachment 631407 [details]
DS configuration for Oracle11g

Comment 3 Kris Verlaenen 2012-10-23 14:52:30 UTC
Looking at ProcessLauncher, it seems you're disposing the session in the same transaction as all the other modifications.  

    @TransactionAttribute
    public String launchProcess() {
        String msg = null;
        try {       
            newJpaSession();
            ...
            ksession.dispose();
        } catch (Throwable ex) {
            throw new RuntimeException(ex);
        } 
        return msg;
    }

Unfortunately that isn't possible, as dispose will release all data etc., and if you do this before the transaction is committed, the data needed to commit the transaction is no longer available.

Disposing the session after the transaction has been committed should solve this.

Comment 4 Radovan Synek 2012-10-24 06:52:00 UTC
Hi Kris, 

you are right - I have tried it with calling dispose() separately and it worked just fine. Thanks for explanation.