Bug 839759 - Drools brings compile error when trying to length-check a Fact's attribute.U
Drools brings compile error when trying to length-check a Fact's attribute.U
Status: NEW
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: Compatibility (Show other bugs)
5.2.0 GA
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Default User
Depends On:
  Show dependency treegraph
Reported: 2012-07-12 14:04 EDT by Rick Wagner
Modified: 2018-01-29 09:05 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Support Patch
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Rick Wagner 2012-07-12 14:04:30 EDT
Description of problem:

Using the 'business_rules_service' quickstart, make the following modifications:

<<<to Customer.java>>>
   private String FIRMA = "aFirma";

    public String getFIRMA() {
        return FIRMA;

    public void setFIRMA(String FIRMA) {
        this.FIRMA = FIRMA;

<<<to MyBusinessRules.drl >>>>
rule "Length check " 
        # FAILS customer: Customer( FIRMA.Length() > 0)
        # FAILS customer: Customer( FIRMA.length() > 0)
        # FAILS customer: Customer( FIRMA.getLength() > 0)
        # FAILS  customer: Customer( FIRMA.toString().getLength() > 0)
        # FAILS customer: Customer( FIRMA.toString().length() > 0)
        $cust : Customer()
        # FAILS eval ($cust.getFIRMA().length >2)
        eval ($cust.getFIRMA().getLength() >2)
       	System.out.println("How can I check length?");

All the above attempts will result in errors like:

2012-07-12 12:45:00,227 DEBUG [org.jboss.soa.esb.listeners.message.ActionProcessingPipeline] (pool-118-thread-1) Unexpected exception caught while processing the action pipeline
org.jboss.soa.esb.actions.ActionProcessingException: Generation raised the following errors: Rule Compilation error : [Rule name='Length check 2']
	com/jboss/soa/esb/routing/cbr/Rule_Length_check_2_0.java (8:614) : The method getLength() is undefined for the type String
Comment 1 Ivan 2012-07-13 07:38:58 EDT
pCtx object contains a map of variableVisibility.  debugging shows that the attribute "FIRMA" is saved a "fIRMA" with first character been converted to the other case  where tk.getAbsoluteName() is FIRMA. this fails in ParserContext.isVariableVisible(String var)[2]

I will run one additional test. I'll change the src attribute to "firma". this will confirm that its not the length thats the problem here.

      if (!propVerifier.isMethodCall() && !returnType.isEnum() && !pCtx.isOptimizerNotified() && pCtx
              && !pCtx.isVariableVisible(tk.getAbsoluteName()) && !tk.isFQCN()) {
            throw new CompileException("no such identifier: " + tk.getAbsoluteName(), expr, tk.getStart());

 if (AbstractParser.LITERALS.containsKey(var) || hasImport(var)) {
      return true;
Comment 3 Rick Wagner 2012-07-13 15:53:38 EDT
Confirmed this *works* under SOA-P 5.3ER4.

JBRULES-3147 references the following fix code from MVEL fix:

It contains:
-              scope.add(ReflectionUtil.getPropertyFromAccessor(m.getName()));
+              String propertyName = ReflectionUtil.getPropertyFromAccessor(m.getName());
+              scope.add(propertyName);
+              propertyName = propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
+              scope.add(propertyName);
Comment 4 Rick Wagner 2012-07-13 15:58:33 EDT
SOA-P 5.3ER4 does not exhibit this bug.  But it has 3 versions of mvel:


Looking at the two likely to be used (outside the gwt war), we see the above code *is* applied to ParserContext.

Note You need to log in before you can comment on or make changes to this bug.