How to get process instance list. on BProc 1.0.2

Hi, I’m using commercial BProc

And I need to get all process instances of process by process id and business key.

In my service I injected BprocHistoricService

and when
bprocHistoricService.createHistoricProcessInstanceDataQuery().processDefinitionKey(processId).processInstanceBusinessKey(businesskey).count()
there is error

Method threw 'java.lang.ClassCastException' exception. Cannot evaluate com.sun.proxy.$Proxy259.toString()

image

Hi,

I just tried to invoke the method you’ve provided, and it works fine.

Are you sure that you invoke exactly the same code that you wrote here

bprocHistoricService.createHistoricProcessInstanceDataQuery().processDefinitionKey(processId).processInstanceBusinessKey(businesskey).count()

and not something like

bprocHistoricService.createHistoricProcessInstanceDataQuery().processDefinitionKey(processId).processInstanceBusinessKey(businesskey).toString()

?

I see the toString() method invocation on the screenshot you provided.

Hi, yes. This is sample of code from service in project
image
.
image

Error is on invocation createHistoricProcessInstanceDataQuery()
image

But does it fail? Does the application stop working after that line? Are there any errors in the app.log? Can you reach the next line of code while debugging?
You screenshot tells that “Evaluate expression” dialog tries invoke the toString() of the Proxy object and this “toString()” invocation fails.

When test I run service method from test and its fails.
When I run app and invoked this method from Service Task of process now process run as expected. I received number of process instances.

I think problem with MainTestContainer init. How I can solve this problem?

Here is a sample that includes a test invoking BProc API: bproc-test-container.zip (91.4 KB)

The test file is SampleBprocIntegrationTest.java

Pay an attention to the modifications in the SampleTestContainer. The process engine must be initialized explicitly.

There is a line:

AppBeans.get(ProcessEngineInitializer.class).initProcessEngine();

in the method:

        @Override
        public void before() throws Throwable {
            if (!initialized) {
                super.before();
                initialized = true;
            }
            setupContext();
            AppBeans.get(ProcessEngineInitializer.class).initProcessEngine();
        }

Thanks!
Tested, this works ok!