Your jar files [the models] need to be in the same drools
package as your DRL file.
So if in the Guvnor you have:
com.domain.project.rules
Business
Rules
Your
DRL file
Then you need to have the model in the same package.
com.domain.project.rules
Business
Rules
Your
DRL file
Models
Jar
1
Jar
2
Jar
3
The objects in each jar don’t have to be in the
com.domain.project.rules package. They can be in any package. You
do need to import the correct objects in your DRL however. The package
you specify in the Guvnor is the package that the individual rules get compiled
into.
From:
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Ike Okafo
Sent: Monday, June 28, 2010 4:32 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Rule Validation/Package Build Error in Guvnor:
ClassNot Found
Hello,
I am new to Drools and have written a rule .DRL file which
contains some
helper function imports from other packages, fact objects imports from
other packages and the rules that act on these facts. The file works well
when I call it from my javacode using the rulebase or knowledgebase approach.
The drl file itself is in its own package.
I now have a requirement to call the same rules from within Guvnor.
The goal is to enable business users modify these rules through the
Guvnor UI and also take advantage of the disable individual rules
feature within guvnor.
My current difficulty is importing and validating the rules
in guvnor,
along with the associated fact jar files and finally interfacing
with guvnor from my code. Any help would be appreciated .
The main error happens when I try to build a binary package
and create
a snapshot of the working rule file I imported for deployment.
When I hit the save and validate configuration button, I get
"class not found" validation errors for all the
classes imported at
the top of the rule file - includingng the helper import functions
and facts used in the rules. Same thing happens when I try to
build the package I get the following errors
"Error importing: <list of all classes in import
statement in rule file>"
Here are the steps I followed in importing the rule file and Jar file
containing the classes
into Guvnor
(1) First within Guvnor I created a package corresponding to
the package path
for for each of the jar files whose classes are
referenced/imported in the rule .DRL file
(2) I created the jar files for each of these packages in eclipse
(3) Imported those jars individually into each of the packages created in
guvnor
using upload model jar function and selecting the
appropriate path as
created in step 1 2 above
(4) Imported the rule file which is in its own package - using the create
package (upload method)
(5) I then try to save and validate the imported rule file in step
5 (this is where the error occurs)
I have already setup my code to call guvnor as follows
RuleAgent agent = RuleAgent.newRuleAgent("guvnor.properties");
RuleBase masterRuleBase = agent.getRuleBase();
guvnor.properties contains only one entry
url = http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/SomePackage.drools/LATEST
It is my understanding that after I import the rule file
I need to save and validate and build the package
in order to point the url to the path above. If I point the url to just
the drl file itself will it work?
i.e url=http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/SomePackage.drools/LATEST.drl
Any help to resolve the class not found error will
be much appreciated
Thanks