Iteration en mode (multi – instanciation) from data coming from a connector (extension)

1
0
-1

Hello,
I am new to Bonita Community Edition on version 2022.1
In the context of a process, I would like to be able to iterate sequentially (multi - instantiation) on a task from the data returned by a connector.
I have implemented a connector that returns a list of plein java beans (class ch.eri.orp.thirdparty.entity.AddressCondition) which is stored within a process variable named addressCondition.
When I launch my process I can see in the bonita logs that the connector has been launched and that it returns the list of bean of type AddressCondition, but unfortunately the multiInstanceIterator object (proposed by the Bonita editor) on which I should be able to iterate does not seem to be referenced.
I have the following stack trace:

2022-06-03T09:54:55,126+0200 | ZRH30479n | INFO  | [ConnectorExecutor-7|254] c.b.c.AddressConditionConnector1 - addressConditions:[ch.eri.orp.thirdparty.entity.AddressCondition@49b2b7e6, ch.eri.orp.thirdparty.entity.AddressCondition@da51ec7]
2022-06-03T09:54:55,126+0200 | ZRH30479n | INFO  | [ConnectorExecutor-7|254] c.b.c.AddressConditionConnector1 - Disconnect
2022-06-03T09:54:55,165+0200 | ZRH30479n | INFO  | [ConnectorExecutor-8|259] c.b.c.AddressConditionConnector1 - Connect to retrieve addressConditions
2022-06-03T09:54:55,166+0200 | ZRH30479n | INFO  | [ConnectorExecutor-8|259] c.b.c.AddressConditionConnector1 - addressConditions:[ch.eri.orp.thirdparty.entity.AddressCondition@36c4f5a2, ch.eri.orp.thirdparty.entity.AddressCondition@38031d0a]
2022-06-03T09:54:55,187+0200 | ZRH30479n | INFO  | [ConnectorExecutor-8|259] c.b.c.AddressConditionConnector1 - Disconnect
2022-06-03T09:54:55,304+0200 | ZRH30479n | WARN  | [Bonita-Worker-1-09|263] o.b.e.w.RetryingWorkExecutorService - THREAD_ID=263 | HOSTNAME=ZRH30479n | TENANT_ID=1 | Work ExecuteFlowNodeWork: flowNodeInstanceId: 160016 (32, false, false, false) failed. The element will be marked as failed. Exception is: org.bonitasoft.engine.core.process.instance.api.exceptions.business.data.SRefBusinessDataInstanceNotFoundException: Unable to find a reference to a business data named 'multiInstanceIterator' of process instance 8004
    wrapped by org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: org.bonitasoft.engine.core.process.instance.api.exceptions.business.data.SRefBusinessDataInstanceNotFoundException: Unable to find a reference to a business data named 'multiInstanceIterator' of process instance 8004
    wrapped by org.bonitasoft.engine.core.process.instance.api.exceptions.SActivityStateExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: org.bonitasoft.engine.core.process.instance.api.exceptions.business.data.SRefBusinessDataInstanceNotFoundException: Unable to find a reference to a business data named 'multiInstanceIterator' of process instance 8004
 exception was generated here:    at org.bonitasoft.engine.core.process.instance.impl.RefBusinessDataServiceImpl.getSARefBusinessDataInstance(RefBusinessDataServiceImpl.java:205)
    at org.bonitasoft.engine.business.data.RefBusinessDataRetriever.getRefBusinessDataInProcess(RefBusinessDataRetriever.java:78)
    at org.bonitasoft.engine.business.data.RefBusinessDataRetriever.getRefBusinessDataUsingFlowNodeContext(RefBusinessDataRetriever.java:68)

Thx for you help

david

Comments

Submitted by daarnone on Fri, 06/03/2022 - 13:06

For information, when doing the test of the connector i got the following:

java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.exception.BonitaRuntimeException: Unable to deserialize object 
<object-stream>
  <map>
    <entry>
      <string>output0</string>
      <list>
        <ch.eri.orp.thirdparty.entity.AddressCondition>
          <clientId>0032037</clientId>
          <onHold>true</onHold>
          <line1>line1</line1>
          <line2>line2</line2>
          <line3>line3</line3>
          <line4>line4</line4>
        </ch.eri.orp.thirdparty.entity.AddressCondition>
        <ch.eri.orp.thirdparty.entity.AddressCondition>
          <clientId>0032032</clientId>
          <onHold>false</onHold>
          <line1>line12</line1>
          <line2>line22</line2>
          <line3>line32</line3>
          <line4>line42</line4>
        </ch.eri.orp.thirdparty.entity.AddressCondition>
      </list>
    </entry>
  </map>
</object-stream>

com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : ch.eri.orp.thirdparty.entity.AddressCondition
class               : java.util.ArrayList
required-type       : java.util.ArrayList
converter-type      : com.thoughtworks.xstream.converters.collections.CollectionConverter
path                : /map/entry/list/ch.eri.orp.thirdparty.entity.AddressCondition
line number         : 6
class[1]            : java.util.HashMap
required-type[1]    : java.util.HashMap
converter-type[1]   : com.thoughtworks.xstream.converters.collections.MapConverter
version             : 1.4.19
-------------------------------

So according to the message , it seems that the ClassLoader running the process can't acces the class of the java bean (ch.eri.orp.thirdparty.entity.AddressCondition) embedded in the connector jar.

Is that correct?

Is it possible to customer bean declared within connector inside of process variable?

Beside the serialization problem , I don't get why the key entry of the map is named outpout0, but in my connector is declared as:

public final static String ADDRESSCONDITION_OUTPUT_PARAMETER = "addressConditions"; protected final 
void setAddressConditions(List addressConditons) {       setOutputParameter(ADDRESSCONDITION_OUTPUT_PARAMETER, addressConditons); 
}

This might be an problem with the Bonita design tool when testing the connector, since the next step seems to recognize the correct key inside the map.

Right now I have read similar older Q&A like

https://community.bonitasoft.com/questions-and-answers/start-process-cus...

https://community.bonitasoft.com/questions-and-answers/connector-return-value-exception

I have also tried to put the connector jar within workspace\tomcat\server\lib\ext as some have suggested.

My next step if it's not working out , is to use Map withe all the field needed to replace the the Bean which isn't really elegant...

No answers yet.
Notifications