Search code examples
javajbpm

jBPM compilation error


Process Compilation error : org.drools.lang.descr.ProcessDescr@4c60d6e9     
com/sample/Process_com_sample_ruleflowsample.java (21:862) : Type mismatch: cannot convert from int to String   
com/sample/Process_com_sample_ruleflowsample.java (29:1151) : Type mismatch: cannot convert from int to String

This is my ruleflowsample.rf under src/main/rules that is throwing the above error.

<?xml version="1.0" encoding="UTF-8"?> 
<process xmlns="http://drools.org/drools-5.0/process"
         xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
         xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
         type="RuleFlow" name="ruleflowsample" id="com.sample.ruleflowsample" package-name="com.sample" >

  <header>
    <imports>
      <import name="com.sample.Employee" />
    </imports>
    <variables>
      <variable name="caffeineIntake" >
        <type name="org.drools.process.core.datatype.impl.type.FloatDataType" />
      </variable>
    </variables>
  </header>

  <nodes>
    <start id="1" name="Start" x="12" y="129" width="48" height="48" />
    <split id="2" name="Gateway" x="101" y="128" width="49" height="49" type="2" >
      <constraints>
        <constraint toNodeId="4" toType="DROOLS_DEFAULT" name="Coffee" priority="1" type="code" dialect="java" >return caffeineIntake&gt;0.105F;</constraint>
        <constraint toNodeId="5" toType="DROOLS_DEFAULT" name="Tea" priority="1" type="code" dialect="java" >return caffeineIntake&gt;0.04F;</constraint>
      </constraints>
    </split>
    <actionNode id="4" name="Coffee" x="198" y="205" width="80" height="48" >
        <action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of coffee cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
    </actionNode>
    <actionNode id="5" name="Tea" x="196" y="61" width="80" height="48" >
        <action type="expression" dialect="java" >String noOfCups = 1;
System.out.println("No of tea cups = "+noOfCups);
System.out.println("caffeineIntake");</action>
    </actionNode>
    <end id="6" name="End" x="386" y="127" width="48" height="48" />
    <join id="7" name="Gateway" x="311" y="127" width="49" height="49" type="2" />
  </nodes>

  <connections>
    <connection from="1" to="2" />
    <connection from="2" to="4" />
    <connection from="2" to="5" />
    <connection from="7" to="6" />
    <connection from="5" to="7" />
    <connection from="4" to="7" />
  </connections>

</process>

I know the error is occurring because of this line: System.out.println("caffeineIntake"); I want to access this input variable i.e. caffeineIntake to perform some operation on it.


Solution

  • The error is not occurring because of this line: System.out.println("caffeineIntake");

    It is occurring because of the Dialect option selection: enter image description here

    Using this option as mvel rather than java resolved the issue.