Bug 1032206 - NPE when accessing tasks using a RuntimeEngine without persistence.
Summary: NPE when accessing tasks using a RuntimeEngine without persistence.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: ER6
: 6.0.0
Assignee: Maciej Swiderski
QA Contact: Jiri Svitak
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-19 17:32 UTC by Marek Baluch
Modified: 2015-06-02 01:35 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:06:52 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Marek Baluch 2013-11-19 17:32:54 UTC
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 10:19:43 UTC
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 13:33:10 UTC
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 10:34:15 UTC
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 11:57:14 UTC
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.