JBPM with Spring as backend service not evaluating #{expression}

270 views Asked by At

I'm having problems with my jbpm application. It does not resolve the #{expression} tags, which, following the redhat course, it should as it states:

The #{requiredDocument} syntax in the name is replaced at runtime with the value of the requiredDocument process variable. This allows it to show different task names, depending on the document the user is required to upload.

This does not work in my case... However on the tutorial he is using business central to deploy it's processes, while in my case I'm using spring The project's structure is the classic kjar-service:

-bpm-application
--bpm-application-service
--bpm-application-kjar

This is my kjar project's pom

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>poc-decision-table-kjar</artifactId>
  <version>0.0.1</version>
  <packaging>kjar</packaging>
  <name>poc-decision-table-kjar</name>
  <properties>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.source>11</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <version.org.kie>7.54.0.Final</version.org.kie>
  </properties>
  <dependencies>
    <dependency>
      <groupId>it.poste</groupId>
      <artifactId>poc-decision-table-model</artifactId>
      <version>0.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm.contrib</groupId>
      <artifactId>jpa-workitem</artifactId>
      <version>7.54.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-model-compiler</artifactId>
      <version>7.54.0.Final</version>
  </dependency>  
  </dependencies>
  <repositories>
    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>https://repository.jboss.org/nexus/content/groups/public/</url>
    </repository>
  </repositories>
  <build>
    <plugins>
      <plugin>
        <groupId>org.kie</groupId>
        <artifactId>kie-maven-plugin</artifactId>
        <version>${version.org.kie}</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>docker</id>
      <activation>
        <property>
          <name>docker</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>additional-install</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <finalName>local</finalName>
                  <descriptors>
                    <descriptor>src/main/assembly/repository.xml</descriptor>
                  </descriptors>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.4</version>
            <executions>
              <execution>
                <id>additional-install</id>
                <phase>install</phase>
                <goals>
                  <goal>install-file</goal>
                </goals>
                <configuration>
                  <file>${project.build.directory}/${project.build.finalName}.jar</file>
                  <pomFile>pom.xml</pomFile>
                  <localRepositoryPath>${project.build.directory}/local-repository/maven</localRepositoryPath>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>openshift</id>
      <activation>
        <property>
          <name>openshift</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>additional-install</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <finalName>local</finalName>
                  <descriptors>
                    <descriptor>src/main/assembly/repository.xml</descriptor>
                  </descriptors>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.4</version>
            <executions>
              <execution>
                <id>additional-install</id>
                <phase>install</phase>
                <goals>
                  <goal>install-file</goal>
                </goals>
                <configuration>
                  <file>${project.build.directory}/${project.build.finalName}.jar</file>
                  <pomFile>pom.xml</pomFile>
                  <localRepositoryPath>${project.build.directory}/local-repository/maven</localRepositoryPath>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

And this is my service's pom

4.0.0 com.example poc-decision-table-service 0.0.1 jar poc-decision-table-service

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.2.RELEASE</version>
</parent>

<properties>
    <version.org.kie>7.54.0.Final</version.org.kie>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.source>11</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <narayana.version>5.9.0.Final</narayana.version>
    <fabric8.version>3.5.40</fabric8.version>
</properties>

<dependencies>
    <dependency>
        <groupId>it.poste</groupId>
        <artifactId>poc-decision-table-model</artifactId>
        <version>0.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.kie</groupId>
        <artifactId>kie-server-spring-boot-starter</artifactId>
        <version>${version.org.kie}</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>

        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>11</source>
                <target>11</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>

    <profile>
        <id>h2</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <dependencies>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>mysql</id>
        <activation>
            <property>
                <name>mysql</name>
            </property>
        </activation>
        <dependencies>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>postgres</id>
        <activation>
            <property>
                <name>postgres</name>
            </property>
        </activation>
        <dependencies>
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
            </dependency>
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>docker</id>
        <activation>
            <property>
                <name>docker</name>
            </property>
        </activation>

        <build>
            <plugins>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>fabric8-maven-plugin</artifactId>
                    <version>${fabric8.version}</version>
                    <configuration>
                        <verbose>false</verbose>
                        <images>
                            <image>
                                <name>apps/${project.artifactId}:${project.version}</name>
                                <build>
                                    <from>fabric8/java-jboss-openjdk8-jdk</from>
                                    <assembly>
                                        <targetDir>/</targetDir>
                                        <inline>
                                            <files>
                                                <file>
                                                    <source>
                                                        ${project.build.directory}/${project.build.finalName}.${project.packaging}
                                                    </source>
                                                    <outputDirectory>deployments</outputDirectory>
                                                    <destName>${project.build.finalName}.${project.packaging}
                                                    </destName>
                                                </file>
                                                <file>
                                                    <source>${project.artifactId}.xml</source>
                                                    <outputDirectory>deployments</outputDirectory>
                                                    <destName>${project.artifactId}.xml</destName>
                                                </file>
                                            </files>
                                            <fileSet>
                                                <directory>src/main/docker</directory>
                                                <outputDirectory>opt/jboss/.m2</outputDirectory>
                                                <includes>
                                                    <include>settings.xml</include>
                                                </includes>
                                            </fileSet>
                                            <fileSet>
                                                <directory>
                                                    ../poc-decision-table-kjar/target/local-repository/maven
                                                </directory>
                                                <outputDirectory>opt/jboss/.m2/repository</outputDirectory>
                                            </fileSet>
                                        </inline>
                                        <user>jboss:jboss:jboss</user>
                                    </assembly>
                                </build>
                            </image>
                        </images>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>install</phase>
                            <goals>
                                <goal>resource</goal>
                                <goal>build</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>openshift</id>
        <activation>
            <property>
                <name>openshift</name>
            </property>
        </activation>

        <properties>
            <fabric8.mode>openshift</fabric8.mode>
            <fabric8.build.strategy>docker</fabric8.build.strategy>
        </properties>

        <build>
            <plugins>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>fabric8-maven-plugin</artifactId>
                    <version>${fabric8.version}</version>
                    <configuration>
                        <verbose>false</verbose>
                        <images>
                            <image>
                                <name>apps/${project.artifactId}:${project.version}</name>
                                <build>
                                    <from>fabric8/java-jboss-openjdk8-jdk</from>
                                    <assembly>
                                        <targetDir>/</targetDir>
                                        <inline>
                                            <files>
                                                <file>
                                                    <source>
                                                        ${project.build.directory}/${project.build.finalName}.${project.packaging}
                                                    </source>
                                                    <outputDirectory>deployments</outputDirectory>
                                                    <destName>${project.build.finalName}.${project.packaging}
                                                    </destName>
                                                </file>
                                                <file>
                                                    <source>${project.artifactId}.xml</source>
                                                    <outputDirectory>deployments</outputDirectory>
                                                    <destName>${project.artifactId}.xml</destName>
                                                </file>
                                            </files>
                                            <fileSet>
                                                <directory>src/main/docker</directory>
                                                <outputDirectory>opt/jboss/.m2</outputDirectory>
                                                <includes>
                                                    <include>settings.xml</include>
                                                </includes>
                                            </fileSet>
                                            <fileSet>
                                                <directory>
                                                    ../poc-decision-table-kjar/target/local-repository/maven
                                                </directory>
                                                <outputDirectory>opt/jboss/.m2/repository</outputDirectory>
                                            </fileSet>
                                        </inline>
                                        <user>jboss:jboss:jboss</user>
                                    </assembly>
                                    <ports>
                                        <port>8090</port>
                                    </ports>
                                </build>
                            </image>
                        </images>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>install</phase>
                            <goals>
                                <goal>resource</goal>
                                <goal>build</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<repositories>
  <repository>
    <id>jboss-public-repository-group</id>
    <name>JBoss Public Repository Group</name>
    <url>https://repository.jboss.org/nexus/content/groups/public/</url>
    <layout>default</layout>
    <releases>
      <updatePolicy>never</updatePolicy>
    </releases>
    <snapshots>
      <updatePolicy>daily</updatePolicy>
    </snapshots>
  </repository>
</repositories>

This is my current task that has the #{expression} that is not evaluated at runtime by the process. Infact when I start the process, it successfully gets completed but on the embedded h2 db the task name is still EndTask-#{codiceEsito}, while I was more expecting to see EndTask-01 (codiceEsito is a String processVariable)

enter image description here

So the question is, am I missing some dependencies needed for that kind of evaluation? I'm stuck on this thing

EDIT: Here is the image taken from the OFFICIAL redhat course on their website, so I guess it is possible somehow, they make it simple as inserting the #{} expression which in my case is not working

enter image description here

EDIT 2: Here is the project on github (the kjar)

0

There are 0 answers