Bug 1032206 - NPE when accessing tasks using a RuntimeEngine without persistence.
NPE when accessing tasks using a RuntimeEngine without persistence.
Status: CLOSED CURRENTRELEASE
Product: JBoss BPMS Platform 6
Classification: JBoss
Component: jBPM Core (Show other bugs)
6.0.0
Unspecified Unspecified
high Severity medium
: ER6
: 6.0.0
Assigned To: Maciej Swiderski
Jiri Svitak
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-19 12:32 EST by Marek Baluch
Modified: 2015-06-01 21:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-08-06 16:06:52 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Marek Baluch 2013-11-19 12:32:54 EST
Description of problem:

Following code will throw NPE when ts.getTasksByProcessInstance(pi.getId()); is called.

<code-snip>
public class JbpmExecutor {


    public RuntimeEngine newRuntime(String... processes) throws Exception {
        RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.getEmpty()
                .addConfiguration("drools.processSignalManagerFactory", DefaultSignalManagerFactory.class.getName())
                .addConfiguration("drools.processInstanceManagerFactory", DefaultProcessInstanceManagerFactory.class.getName());
        
        for (String process : processes) {
        	builder.addAsset(ResourceFactory.newClassPathResource(process), ResourceType.BPMN2);
        }
        
//        for (String ruleFile : ruleFiles) {
//            builder.addAsset(ResourceFactory.newClassPathResource(ruleFile), ResourceType.DRL);
//        }
        
        RuntimeManager manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(builder.get(), "Singleton " + UUID.randomUUID().toString());
        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        
        return runtime;
    }

    public static void main(String ... args) throws Exception {
		JbpmExecutor executor = new JbpmExecutor();
		RuntimeEngine runtime = executor.newRuntime("xxx.bpmn2");
		
		ProcessInstance pi = runtime.getKieSession().startProcess("BPMN2IntermediateThrowEscalationEvent");
		System.out.println(pi.getState() == ProcessInstance.STATE_COMPLETED);
		
		TaskService ts = runtime.getTaskService();
		// Throws NPE. I would consider this a bug which is not yet reported. 
		System.out.println(ts.getTasksByProcessInstanceId(pi.getId()));
	}
    
}
</code-snip>
Comment 1 Maciej Swiderski 2013-11-20 05:19:43 EST
Marek,

that is sort of expected behavior as you don't configure task service and thus it's not available. You use Empty builder which means you need to setup everything manually, while you could use DefaultInMemory to have task service configured and process engine in memory only.
The improvement we could apply here is that it shall throw an exception on getTaskService method when it is not configured with meaningful message instead of NPE.

Wdyt?
Comment 2 Marek Baluch 2013-11-20 08:33:10 EST
Maciej,

I believe that would be a fitting solution. Something like UnsupportedOperationException with a message explaining why it's not supported.

@mb
Comment 3 Maciej Swiderski 2013-11-21 05:34:15 EST
alright, exception is now thrown in case task service is not configured to avoid further NPE.

jbpm
master:
https://github.com/droolsjbpm/jbpm/commit/66a00615ccb8ddc863e9f0023db209d9fd18e7d1

6.0.x:
https://github.com/droolsjbpm/jbpm/commit/264f70ba67d045eb94a9b7c2a575fecf43196a6e
Comment 4 Jiri Svitak 2014-01-03 06:57:14 EST
Verified in BPMS 6 ER7 (6.0.1-redhat-2).

Note You need to log in before you can comment on or make changes to this bug.