Bug 754093 - Declarative type extension not working properly
Declarative type extension not working properly
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRM (Guvnor) (Show other bugs)
BRMS 5.3.0.GA
Unspecified Unspecified
unspecified Severity high
: ER7
: BRMS 5.3.0.GA
Assigned To: manstis
Lukáš Petrovický
: Regression
Depends On: 796612
  Show dependency treegraph
Reported: 2011-11-15 06:53 EST by Zuzana Krejčová
Modified: 2016-07-31 21:12 EDT (History)
5 users (show)

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

Attachments (Terms of Use)
rule (119.27 KB, image/png)
2012-04-25 11:20 EDT, Zuzana Krejčová
no flags Details
stacktrace (6.20 KB, text/plain)
2012-04-25 11:20 EDT, Zuzana Krejčová
no flags Details
repository (26.51 KB, application/xml)
2012-04-25 11:56 EDT, Zuzana Krejčová
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBRULES-3417 Blocker Resolved 5.3.x Regression: SuperTypeName for a Declared Type extending reports as Object 2015-12-12 07:40 EST
JBoss Issue Tracker JBRULES-3418 Critical Resolved 5.3.x Regression: Declared Super-Types: Compile-time error 2015-12-12 07:40 EST

  None (edit)
Description Zuzana Krejčová 2011-11-15 06:53:11 EST
Description of problem:

It should be possible (according to docs) to extend 

A) Facts inside the same Declarative Model: 
Works well.

B) Facts from a different D. Model from the same Package: 
It is NOT possible to do that in Guvnor - while creating a new Fact, there isn't the other (parent) Fact listed as a type to extend. There's a workaround for that, though not very good - export the repository, edit the xml so that the model has something like "declare fact extends anotherFact ...some fields... end", import it back into Guvnor.

C) Imported Java classes: 
This does not work at all. Not even after manually editing the repository.xml.

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

BRMS 5.3.0 dev5
Comment 1 manstis 2012-01-22 05:23:31 EST
Guvnor documentation states to extend a POJO you need to complete the following:- Extending a Java class

To extend a Java class the following steps need to be completed:-

* Import the applicable Java JAR into Guvnor

* If the Java package name in which the class belongs is different to the Guvnor package name in to which the JAR has been imported ensure the Guvnor package imports the class from which you want to extend. This is normally completed for you automatically when you upload a JAR model however if you have multiple classes with the same name in the JAR you should check the appropriate one has been imported.

* Within the Declarative Modelling screen define an empty type (i.e. with no fields) of the same name as that you want to extend.

* Create a new declarative type as appropriate, extending the empty declaration created in the preceeding step.

Please clarify what does not work as documented?
Comment 2 Zuzana Krejčová 2012-01-23 05:28:32 EST
Doing it this way works - though I'd swear this bit of information (define an empty type of the same name, then extend this one) got added/changed after I reported the issue.. Never mind. 

Now I can't even find any specific mention of extending a fact from a different declarative model in the same package, as in B) - which still doesn't work.

Tested on BRMS 5.3.0 ER2.
Comment 3 manstis 2012-01-23 07:01:43 EST
Hi Zuzana, 

I don't know why you couldn't find C) (it has always been this way in both Drools' DRL and Guvnor) but as you say, never mind.

I will hopefully work on B) soon - it should be quite simple (we only load declared types for use in the screen from the model being opened, I need to change it to load all Facts in all declarative models in the package).


Comment 4 manstis 2012-01-30 06:39:36 EST
Fixed (B) and back-ported to 5.3.x branch.

(A) and (C) no longer issues.
Comment 5 Ryan Zhang 2012-02-15 04:12:15 EST
Please verify the issue on 5.3 ER4.
Comment 6 Zuzana Krejčová 2012-02-21 07:31:28 EST
Case B is still not working in ER4. 
What it does now:
It allows you to choose a fact to extend, but upon save, it changes it to Object - this, obviously, does not bring anything new to the fact...

Say I have a model with fact F1 which has a field f1. Then I create another model in the same package and create a new fact in it, F2, and choose it's to extend the fact F1. I add a field f2 to the fact and save the model.
Upon save, i see the "F2 extends F1" change to "F2 extends Object". Field f1 is not accessible from fact F2.
Comment 7 manstis 2012-02-21 07:46:28 EST
This is due to a regression in Drools Expert. I have asked for a fix made to master to be back-ported... and am awaiting confirmation it has been completed.
Comment 8 Anne-Louise Tangring 2012-03-28 10:48:37 EDT
Setting Blocker flag as agreed on in triage meeting.
Comment 9 JBoss JIRA Server 2012-03-30 08:50:03 EDT
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3418 to Coding In Progress
Comment 10 JBoss JIRA Server 2012-03-30 08:50:08 EDT
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3417 to Coding In Progress
Comment 11 JBoss JIRA Server 2012-03-30 08:54:34 EDT
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3418 to Resolved
Comment 12 JBoss JIRA Server 2012-03-30 08:54:42 EDT
Michael Anstis <michael.anstis@gmail.com> updated the status of jira JBRULES-3417 to Resolved
Comment 13 Ryan Zhang 2012-04-23 03:36:41 EDT
Update status to ON_QA. Please verify them against ER6.
Comment 14 Zuzana Krejčová 2012-04-25 11:19:16 EDT
I am sorry to say it still needs some tweaking.

I got "[rule] Unable to validate this asset. (Check log for detailed messages)." upon validation of a rule using such Facts (B) or either of the models.

I have a model parentModel:
declare ParentFact
    parentFiled: String

and another one childModel:
declare ChildFact
    childFiled: String

and a simple rule using both of those.

There's also NPE in the server log, "Unable to build asset." at org.drools.base.ClassTypeResolver.resolveType(ClassTypeResolver.java:130). 

See attachments for the rule and the stacktrace.
Comment 15 Zuzana Krejčová 2012-04-25 11:20:06 EDT
Created attachment 580190 [details]
Comment 16 Zuzana Krejčová 2012-04-25 11:20:37 EDT
Created attachment 580192 [details]
Comment 17 manstis 2012-04-25 11:23:14 EDT
Please attach your repository export too, it'll make tracking down the problem much easier. Thanks, Mike
Comment 18 Zuzana Krejčová 2012-04-25 11:56:08 EDT
Created attachment 580201 [details]

I have found out that this Error happens due to my model names, when the first letters aren't like this: childModel, ParentModel. 
Meaning, if I havechildModel, ParentModel, it is okay. 
If I have childModel, parentModel it is not, same with ChildModel and whatever.
Comment 19 manstis 2012-04-25 17:58:24 EDT
I suspect this relates to the ordering of Declarative model names. The DRL for the attached repository reads:-

4.	|	declare ChildFact extends ParentFact
5.	|	    childField: Boolean
6.	|	end
7.	|	
8.	|	declare ParentFact
9.	|	    parentField: String
10.	|	end

Hence we are trying to extend a type before the super-type is declared. This is further substantiated if you try to build the package - it fails :( We need to add some code to order the DRL by parent->child types where one extends another.
Comment 20 manstis 2012-04-27 11:35:13 EDT
Problem was that the sub-type was being declared in package DRL before super-type. Fixed in master and 5.3.x branch (https://github.com/droolsjbpm/guvnor/commit/7b32666c4451a075074a5f9a69a85e85dc093015)
Comment 24 Ryan Zhang 2012-05-14 04:16:16 EDT
The fixed for this issue should be included in ER7. Please do verification on it.

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