5 Replies Latest reply on Mar 28, 2007 3:32 PM by Ronald van Kuijk

    EL Condition failing

    falazar Novice

      The server is throwing an error when trying to compare a variable against a condition:


      Caused by: org.jbpm.JbpmException: couldn't evaluate expression '#{amount > 1000}'
      at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:33)
      at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:20)
      at org.jbpm.graph.node.Decision.execute(Decision.java:119)
      ... 63 more
      Caused by: org.jbpm.jpdl.el.ELException: An exception occured trying to convert String "234.56" to type "java.lang.Long"
      at org.jbpm.jpdl.el.impl.Logger.logError(Logger.java:482)
      at org.jbpm.jpdl.el.impl.Logger.logError(Logger.java:499)
      at org.jbpm.jpdl.el.impl.Logger.logError(Logger.java:567)
      at org.jbpm.jpdl.el.impl.Coercions.coerceToPrimitiveNumber(Coercions.java:441)
      at org.jbpm.jpdl.el.impl.Coercions.applyRelationalOperator(Coercions.java:927)
      at org.jbpm.jpdl.el.impl.RelationalOperator.apply(RelationalOperator.java:86)
      at org.jbpm.jpdl.el.impl.GreaterThanOperator.apply(GreaterThanOperator.java:120)
      at org.jbpm.jpdl.el.impl.BinaryOperatorExpression.evaluate(BinaryOperatorExpression.java:170)
      at org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:264)
      at org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:191)
      at org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator.evaluate(JbpmExpressionEvaluator.java:29)
      ... 65 more


      Definition fragment:


      <![CDATA[#{amount > 1000}]]>


      <![CDATA[#{amount <= 1000}]]>



      Thanks,
      James Ratcliff

        • 1. Re: EL Condition failing
          falazar Novice

          Definition Fragment Repost:


          <decision name="Approve Test 1">
          <transition name="continue" to="Pending PR > 1000">
          <condition><![CDATA[#{amount > 1000}]]></condition>
          </transition>
          <transition name="approve" to="Approved PR">
          <condition><![CDATA[#{amount <= 1000}]]></condition>
          </transition>
          </decision>


          • 2. Re: EL Condition failing
            falazar Novice

             

            <decision name="Approve Test 1">
             <transition name="continue" to="Pending PR > 1000">
             <condition><![CDATA[#{amount > 1000}]]></condition>
             </transition>
             <transition name="approve" to="Approved PR">
             <condition><![CDATA[#{amount <= 1000}]]></condition>
             </transition>
             </decision>
            


            • 3. Re: EL Condition failing
              dslevine Newbie

              Without having looked at the JBPM source code in this section, it looks like its doing a Double to Long comparison and getting an error. Would

              #{ amount > 1000.00 }

              make a difference? Or something like

              #{ amount > (Double) 1000.00 }

              ? (i'm not sure of the syntax of casting in EL.)

              d

              • 4. Re: EL Condition failing
                dslevine Newbie

                re-reading the error message, it looks like it uses the right half of the expression to determine the type, and then attempts to convert the left half to that type. (check the source code to confirm.) so I'd still suggest the same plan -- figure out how to make the right side of the equation a double.

                And please post your eventual solution for others to see who might need to do this eventually.

                • 5. Re: EL Condition failing
                  Ronald van Kuijk Master

                  You need to put a converter on in the jsf page if the variable is not initialized in java code as a Long/Int/whatever before it is firstly used in a page. For this reason I'd like to have the type in the definition as well.