0 Replies Latest reply on Jun 20, 2014 6:58 AM by Laura delli Paoli

    JBAS010152: APPLICATION ERROR: transaction still active in request with status 0 on creating thread in Custom WorkItemHandler

    Laura delli Paoli Master

      Hello everybody,

      I'm trying to simulate a jBPM workflow handler for a long running task (In truth this task can last some seconds or some hours).

      In jBPM 5.4 I handled this issue launching my job in a separate thread and completing the workItem after resuming the KnowledgeSession.

      Now I'm migrating to jBPM6 and I'd love to know REST API and let jBPM manage its sessions, so I implemented my executeWorkItem method in a class implementing WorkItemHandler interface:


      public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

        final long pid = workItem.getProcessInstanceId();

        trace.info("this is RunTaskHandler for process " + pid);

        final long wiId = workItem.getId();

        trace.info("this is the wiId " + wiId);


        new Thread(new Runnable() {

        public void run() {

        int procRes = -1;

        Map<String, Object> result = new HashMap<String, Object>();

        try {

        trace.info("I am simulating a LongRunning Task!!");

        result.put("RunTaskExitValue", new Integer(0));


        JBpmRemoteServices.getInstance().completeWorkItemViaRestAPI(wiId, result);

        trace.info("thread completed");

        } catch (Exception e) {

        throw new RuntimeException("Error encountered while invoking ws operation asynchronously", e);







      and completeworkitemViaRESTAPI:

      public void completeWorkItemViaRestAPI(long workItemId, Map<String, Object> results) throws MalformedURLException {

        KieSession ksession = engine.getKieSession();

        trace.info("KieSession created!");

        WorkItemManager workItemManager = ksession.getWorkItemManager();

        trace.info("WorkItemManager created!");

        workItemManager.completeWorkItem(workItemId, results);



      On running my process from the console I get the following trace:


      18:50:43,754 INFO  [*****] (http- this is LogTaskHandler for process 230

      18:50:43,794 INFO  [stdout] (http- Preparing parameters

      18:50:43,808 INFO  [*****] (http- this is RunTaskHandler for process 230

      18:50:43,835 INFO  [******] (http- this is the wiId 388

      18:50:43,877 ERROR [org.jboss.as.txn] (http- JBAS010152: APPLICATION ERROR: transaction still active in request with status 0


      Can anyone help me?