cancel
Showing results for 
Search instead for 
Did you mean: 

Declared value has type org.activiti.engine.impl.el.Fixed

dognose
Champ in-the-making
Champ in-the-making
Hello Guys,

i'm currently working with Custom Extensions for the Designer.
What i'm trying to do, is setup a Mail-Task that uses my internal template-system
for sending mails.

The extension of AbstractCustomServiceTask declares 2 fields: mailTemplateID (String) and receiver (string)
So, i also added those 2 Attributes to the JavaDelegate that should call my mailService-Instance.

however, i get an exception, when the execution arrives at this task:


07:20:48,812 SCHWERWIEGEND [org.activiti.engine.impl.interceptor.CommandContext] (http–0.0.0.0-8090-3) Error while closing command context: org.activiti.engine.ActivitiException: Incompatible type set on field declaration 'mailTemplateID' for class taskDelegations.MyMailTaskDelegation. Declared value has type org.activiti.engine.impl.el.FixedValue, while expecting java.lang.String
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.applyFieldDeclaration(ClassDelegate.java:192) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:165) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:135) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:112) [activiti-engine-5.10.jar:5.10]
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44) [activiti-engine-5.10.jar:5.10]


Any hints?
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Fields used by field-injection should be of type "Expression", and should be resolved when needed, using the passed-in DelegateExecution in the execute() method:


public class ReverseStringsFieldInjected implements JavaDelegate {

  private Expression text1;
  private Expression text2;

  public void execute(DelegateExecution execution) {
    String value1 = (String) text1.getValue(execution);
    execution.setVariable("var1", new StringBuffer(value1).reverse().toString());

    String value2 = (String) text2.getValue(execution);
    execution.setVariable("var2", new StringBuffer(value2).reverse().toString());
  }
}

dognose
Champ in-the-making
Champ in-the-making
Sry, got to dig this out again:

I'm now using The Expressions as mentioned above:

public class MyMailTaskDelegation implements org.activiti.engine.delegate.JavaDelegate {

private Expression mailTemplateId;
private Expression internalUserId;
private Expression externalAdress;
private Expression externalName;

@Override
public void execute(DelegateExecution execution) throws Exception {


with the implementation of the AbstractCustomServiceTask as follows:


@Runtime(delegationClass = MyMailTask.DELEGATION)
public class MyMailTask extends AbstractCustomServiceTask {
  /*

static strings here

*/
   @Property(type = PropertyType.TEXT, displayName = MyMailTask.FIELD_NAME_TEMPLATE_ID, required = true)
@Help(displayHelpShort = MyMailTask.FIELD_HELP_TEMPLATE_ID)
private String mailTemplateId;

@Property(type = PropertyType.TEXT, displayName = MyMailTask.FIELD_NAME_INTERNAL)
@Help(displayHelpShort = MyMailTask.FIELD_HELP_INTERNAL)
private String internalUserId;

@Property(type = PropertyType.TEXT, displayName = MyMailTask.FIELD_NAME_EXTERNAL_MAIL)
@Help(displayHelpShort = MyMailTask.FIELD_HELP_EXTERNAL_MAIL)
private String externalAdress;

@Property(type = PropertyType.TEXT, displayName = MyMailTask.FIELD_NAME_EXTERNAL_NAME)
@Help(displayHelpShort = MyMailTask.FIELD_HELP_EXTERNAL_NAME)
private String externalName;

now, in Designer i set
templateId=LostPassword
internalUserId=#{requestingUserId}

However, Activiti injects the internalUserId as an Instance of Type FixedValue and therefore getValue() will return #{requestingUserId}
instead of 4878 or whatever evaluated id of given user.

Do i need to mark the Properties as "dynamic" in any way?

I noticed that the Designer generates the following XML:


<serviceTask id="servicetask3" name="MyMailTask" activiti:class="my.namespace.taskDelegations.MyMailTaskDelegation">
      <extensionElements>
        <activiti:field name="mailTemplateId">
          <activiti:string>LostPassword</activiti:string>
        </activiti:field>
        <activiti:field name="internalUserId">
          <activiti:string>${requestingUserId}</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>

but should be


<serviceTask id="servicetask3" name="MyMailTask" activiti:class="my.namespace.taskDelegations.MyMailTaskDelegation">
      <extensionElements>
        <activiti:field name="mailTemplateId">
          <activiti:string>LostPassword</activiti:string>
        </activiti:field>
        <activiti:field name="internalUserId">
          <activiti:expression>${requestingUserId}</activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>

So, is this a designer "Bug", or is it because the Properties in "MyMailTask" are defined as Strings?
But i cannot declare them as Expression or JuelExpression, because the namespace org.activiti.engine.impl.el is not available
in the DesignerExtension project.

Edit:
If i manually change the XML from <activiti:string> to <activiti:expression> it works as expected.

dognose
Champ in-the-making
Champ in-the-making
giving this a tiny bump:

How can i make activiti to generate <activiti:expression> instead of <activiti:string> in the resulting XML file?
(see example from last post)

trademak
Star Contributor
Star Contributor
Hi,

Which version of the Designer are you using? This is working in the latest release.

Best regards,

dognose
Champ in-the-making
Champ in-the-making
Updated to the latest version.
You're right. It works now as expected Smiley Wink