Task assignment by DMN fails

Hello,

I try to assign tasks by a DMN like described in the example on GitHub

Unfortunately the code breaks in the TaskDecorator.class in org.camunda.bpm.engine.impl.task of the camunda-engine-7.18.0-alpha4.jar with the error message of Expression did not resolve to a string or collection of strings.
I’ve tried this with older Camunda versions as well with the same result.

The variable value in the code block below is filled with user Ids by the DMN output with the value of

List(x195620, z843524, u734721, demo)

@SuppressWarnings({ "rawtypes", "unchecked" })
  protected void initializeTaskCandidateUsers(TaskEntity task, VariableScope variableScope) {
    Set<Expression> candidateUserIdExpressions = taskDefinition.getCandidateUserIdExpressions();
    for (Expression userIdExpr : candidateUserIdExpressions) {
      Object value = userIdExpr.getValue(variableScope);

      if (value instanceof String) {
        List<String> candiates = extractCandidates((String) value);
        task.addCandidateUsers(candiates);

      } else if (value instanceof Collection) {
        task.addCandidateUsers((Collection) value);

      } else {
        throw new ProcessEngineException("Expression did not resolve to a string or collection of strings");
      }
    }
  }

Here below my pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany</groupId>
  <artifactId>order-process</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>Camunda Spring Boot Application</name>
  <description>Spring Boot Application using [Camunda](http://docs.camunda.org).</description>

  <properties>
    <camunda.version>7.18.0-alpha4</camunda.version>
    <springBoot.version>2.7.3</springBoot.version>

    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <version.java>11</version.java>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <failOnMissingWebXml>false</failOnMissingWebXml>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-bom</artifactId>
        <version>${camunda.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>org.camunda.bpm.dmn</groupId>
        <artifactId>camunda-engine-dmn-bom</artifactId>
        <version>${camunda.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${springBoot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
    </dependency>
    <!-- Use GraalVM JavaScript for JDK > 14 -->
    <dependency>
      <groupId>org.graalvm.js</groupId>
      <artifactId>js</artifactId>
      <version>21.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.graalvm.js</groupId>
      <artifactId>js-scriptengine</artifactId>
      <version>21.1.0</version>
    </dependency>

    <!-- Add your own dependencies here, if in compile scope, they are added to the jar -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.extension</groupId>
      <artifactId>camunda-bpm-junit5</artifactId>
      <version>1.0.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.assert</groupId>
      <artifactId>camunda-bpm-assert</artifactId>
      <version>12.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.extension</groupId>
      <artifactId>camunda-bpm-process-test-coverage-junit5</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>camunda-bpm-nexus</id>
      <name>Camunda Maven Repository</name>
      <url>https://artifacts.camunda.com/artifactory/public/</url>
    </repository>
  </repositories>

  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${springBoot.version}</version>
        <configuration>
          <layout>ZIP</layout>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <configuration>
          <mainClass>com.mycompany.CamundaApplication</mainClass>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.2</version>
      </plugin>
    </plugins>
  </build>

</project>

I’ve tried the same with Java verion 1.8 with the same result.

Is this a bug?
Is there any workaround known by somebody?

If needed I can provide my dmn and bpmn files
Thanks a lot for your help.

Michael

Hi @michael1,

I’ve tried the examle you mentioned in the version from github and in the latest alpha version.

Both work fine.

I’ve now updated the pom with the current versions and pushed it to github.

There is no additional code to the SpringBootApplication and a test class.

Could you elaborate more about your setup the error that you see here? And add a stacktrace?

Hope this helps, Ingo

Hi Ingo,

thanks a lot! I’ve tried the example as well and it worked.

The variable expected from the TaskDecorator should be a format like this [demo, f574398] to get it work.

The differences to my own project was that the folder src\main\resources\META-INF\services with the file org.camunda.feel.valuemapper.CustomValueMapper was missing.

Everything is working now!

Have a good day!

Michael