Groovy Connector Exception while evaluating expression

Hi folks,

I’m having occasionally this exception thrown:
org.bonitasoft.connectors.scripting.GroovyConnector - Exception : Exception while evaluating expression

I set up a Groovy script connector to retrieve user details using the code as below:

import org.ow2.bonita.util.AccessorUtil;

AccessorUtil.getIdentityAPI().getUser(createdBy).getEmail();

where “createdBy” is a global variable in text as workflow starts.

I’m launching simultaneously several workflow at a time (5 started over 30 sec.) for testing. Only one got exception thrown. Each time the global variable “createdBy” has the same valid value.

This is what I got as cause of error:

java.lang.IllegalStateException: RESTUser has not been set up using setUser(String user)!Problem may be:

  • you did not inform the REST user in the jass file (e.g. adding de option: restUser=“restuser”)
    at org.ow2.bonita.identity.auth.RESTUserOwner.getUser(SourceFile:49)
    at org.ow2.bonita.facade.interceptor.ClientRemoteAPIInterceptor.invoke(SourceFile:69)

What does that mean? How can the exception get thrown with the same scenario? Can I improve my code? Any idea is welcome.

Thanks by advance.

Hi,

did you have the same issue when you use the provided variable apiAccessor to retrieve your API? I.e.

apiAccessor.getIdentityAPI()

instead of

AccessorUtil.getIdentityAPI()

Regards,
Elias

Hi Elias,

I’ll try this. You are suggesting:

import org.ow2.bonita.facade.IdentityAPI;

apiAccessor.getIdentityAPI().getUser(createdBy).getEmail();

I read from the documentation that the getEmail() method of Interface User is Deprecated.
Are we supposed to do this with Interface ContactInfo?

Thank you for the tip.
Best regards

Hi,

yes, use ContactInfo to retrieve the email address, please. You can use, for instance, getProfessionalContactInfo().getEmail().

Hi,

We followed this track. It works well. We have not yet encountered the same problem since we’ve made change.

Thanks!