Bug 1000403

Summary: Functions not recognized
Product: [Retired] JBoss BRMS Platform 6 Reporter: Jiri Locker <jlocker>
Component: Migration ToolAssignee: Neus Miras <nmirasch>
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Svitak <jsvitak>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0.0CC: etirelli, jsvitak, mbaluch, pzapataf, trikkola
Target Milestone: ER1Keywords: TestBlocker
Target Release: 6.0.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
Cause: Using a DRL function in any guided rule. Consequence: The rule using function declared in a DRL file cannot be validated successfully. Workaround (if any): None. Result:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 19:58:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
5.6.1 repository with the example
none
5.6.1 repository with the example, just the repo zipped none

Description Jiri Locker 2013-08-23 11:44:12 UTC
Description of problem:
I have a function defined according to documentation [1] and working in Guvnor 5.x. After migrating to Workbench, the function is listed in "Others" section and opens in default editor. Validation is not available. When the function is used in DRL rule I get compiler error upon validation:

Unable to Analyse Expression System.out.println(hello("Jiri"));: [Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.hello(java.lang.String)] [Near : {... System.out.println(hello("Jiri")); ....}] ^ [Line: 5, Column: 0]

Version-Release number of selected component (if applicable):
ER1

How reproducible:
-

Steps to Reproduce:
1.
2.
3.

Actual results:
- Missing UI support (Function Editor with validation).
- Functions not recognized in rules.

Expected results:
not( Actual results )

Additional info:

Comment 2 manstis 2013-08-30 11:31:20 UTC
Hello,

Functions are created as plain DRL in 6.0.x (there is no explicit "New Function"). Functions should appear under the "DRL" section in Project Explorer. I checked operation of creating a new function and rule with 6.0.x (in the mortgages project):-

func1.drl
---------
function String hello(String name) {
    return "Hello "+name+"!";
}

rule1.drl
---------
rule "using a static function"
when 
    eval( true )
then
    System.out.println( hello( "Bob" ) );
end

Both Validated OK (after a fix I've made; see below) and the Project built OK.

I'll assign this to Jervis to check data-migration; but since (AFAIK) data migration is not supported as part of the Productization think this BZ is no longer a blocker.

Comment 4 manstis 2013-08-30 11:34:48 UTC
@Jervis, 

Could you please check functions in 5.x are migrated as .drl in 6.0.x (I had a quick look at the code and it appears to do so; but Jiri is reported a migrated function appears under "Other" and not "DRL" in Project Explorer).

@Jiri,

Can you try migrating your test project again (in case there have been other fixes that ensure functions are migrated as DRL).

Thanks.

Comment 10 Jiri Svitak 2014-01-14 09:35:28 UTC
Verified in BRMS 6 ER7.

I've used Michael's steps from comment #2. Rule validation didn't produce any error nor the project deployment operation. Function are correctly listed in 'DRL' section as is should be.

Comment 11 Jiri Svitak 2014-01-14 14:21:02 UTC
I've tried also to use Guided rule editor and the problem persists:

Unable to Analyse Expression System.out.println( hello( "Bob" ) );: [Error: unable to resolve method using strict-mode: org.drools.core.spi.KnowledgeHelper.hello(java.lang.String)] [Near : {... System.out.println( hello( "Bob" ) ); ....}] ^ [Line: 3, Column: 0]

(I've used free form drl.)

Comment 13 Toni Rikkola 2014-01-15 12:54:17 UTC
Created attachment 850483 [details]
5.6.1 repository with the example

Comment 16 Toni Rikkola 2014-01-23 12:21:34 UTC
Created attachment 854352 [details]
5.6.1 repository with the example, just the repo zipped

Comment 17 Neus Miras 2014-01-23 14:03:02 UTC
The package reference is now added to the header of the function. It is done in this commit:

6.0.x
https://github.com/droolsjbpm/drools-wb/commit/e23b8ce96de630429c59aca4592caaa494da2046

After this change the function passes the DRL validation but not the Guided editor rule validation. I've tried a DRL with the same code and it works right. 

I've tried to create a new function and I've got the same error message using that from the guided rule editor. It seems to be related to the strict-validation more than the migrated data.

Comment 20 manstis 2014-01-23 17:21:08 UTC
The same problem probably occurs for Guided Templates and Guided Decision Tables.

Comment 23 Lukáš Petrovický 2014-02-07 16:19:02 UTC
This no longer has a target release of 6.0.0.

Comment 24 Jiri Svitak 2014-03-03 10:20:19 UTC
I have tested again with BPMS 6.0.1.ER1, drl files pass, guided rules now work too as well.

QE test suite currently covers only drl files, so updating the qe_test_coverage flag. For further functions issues please file rather a new BZ.

Verified.