dialect java is not loading the facts
by sanintel3
Hi,
There is a strange behaviour in terms of loading the facts using dialect
java and mvel.
Our requirement is that we should support dynamic changes to fact objects in
the application without a restart. So, to achieve that I am using jar
classloader to load the fact objects into memory. So before constructing
RuleBase I am switching the current class loader context to jar classloader.
By doing this, all the imported facts getting resolved if I use mvel dialect
where as if I use java dialect it's not able to resolve the fact. Can
someone help on how to resolve this issue.
I can't use mvel dialect as it's behaving strangely in case of accumulate.
So I need to use java dialect only.
Please let me know why java dialect is considering the facts only from
classpath. It's not loading from current classloader's context
Below is the code to switch classloader context
Thread.currentThread().setContextClassLoader(jarClassLoader);
InputStream is = //reads from jar content
RuleBase ruleBase = RuleBaseLoader.getInstance().loadFromReader(
new InputStreamReader(is));
StatelessSession statelessSession = ruleBase.newStatelessSession();
statelessSession.executeWithResults(facts);
--
View this message in context: http://drools.46999.n3.nabble.com/dialect-java-is-not-loading-the-facts-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Guvnor Sample Rule
by Sumeet Karawal
Hi,
I am trying to create rule in Guvnor and runnig it in Java Application on
Eclipse.
I have gone through the mortgages example provided in the distribution. I
am not sure that I am doing it correctly The steps I did are as follows :
1) Uploaded a POJO jar in Guvnor
2) Created a rule for checking the value of POJO data member
3) Built the package
4) Downloaded the ChangeSet.xml provided
5) Imported that ChangeSet.xml in Eclipse project under com.test package.
6) Created KnowledgeBase and fired the rules
My POJO :
package com.test;
public class CardHolder {
private int accno;
private double discount;
public int getAccno() {
return accno;
}
public void setAccno(int accno) {
this.accno = accno;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
}
My Rule Running Class :
package com.test;
import org.drools.KnowledgeBase;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentFactory;
import org.drools.io.Resource;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class Discount_Provider {
public static void main(String[] args) {
CardHolder c1 = new CardHolder();
c1.setAccno(1005);
try{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
ksession.insert(c1);
ksession.fireAllRules();
System.out.println("The discount applied is : "+
c1.getDiscount());
}
catch (Exception ex)
{
System.out.println("Exception is : "+ex);
}
}
private static KnowledgeBase readKnowledgeBase()
{
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent
("DiscAgent");
Resource changeset = ResourceFactory.newClassPathResource
("com/test/ChangeSet.xml");
kagent.applyChangeSet(changeset);
KnowledgeBase kbase = kagent.getKnowledgeBase();
kagent.dispose();
return kbase;
}
}
My Rule Content :
1.|rule "Discount_CardHolder"
2.| dialect "mvel"
3.| when
4.| $c : CardHolder( accno > 1001 )
5.| then
6.| $c.setDiscount( 10 );
7.| update( $c );
8.|end
Link from where I download the ChangeSet from Guvnor :
Change Set:
|-------------------------------------------------------------------------------------------------------------------------------------------->
|http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/TestPackage/LATEST/ChangeSet.xml |
|-------------------------------------------------------------------------------------------------------------------------------------------->
>-------------|
|(Embedded |
|image moved |
|to file: |
|pic19477.gif)|
>-------------|
Contents of ChangeSet.xml :
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>
<add>
<resource
source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Test...'
type='PKG' />
</add>
</change-set>
Errors that I get :
(null: 3, 175): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
because 1) could not find the document; 2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
(null: 3, 175): cvc-elt.1: Cannot find the declaration of element
'change-set'.
(null: 4, 10): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
because 1) could not find the document; 2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
(null: 5, 130): schema_reference.4: Failed to read schema document
'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...',
because 1) could not find the document; 2) the document could not be read;
3) the root element of the document is not <xsd:schema>.
The discount applied is : 0.0
I am not able to get what should be done to make it run properly. Earlier
also I had tried to do this but faced many issues. By referring the
Mortgages example I tried to create the calling class. It would be very
helpful if some body could help me on this.
Thanks & Regards,
Sumeet
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
13 years, 3 months
[guvnor] Formula builder (or freeform drl builder) for Guided Editor (business rule)
by dhartford
Hey all,
I'm using only Guvnor for my rule creation and testing to feel-out how well
it would handle being the sole BRMS for the 80% scenarios. I understand the
Drools IDE definitely has more power and features, but I'm looking at ways
to give Business Analyst/non-coders more access and ability to interact with
rules.
One of the tricky areas I've run into is trying to always look back to the
model to know what fields are accessible when I'm trying to do any
checks/calculations/expressions/formulas using other fields or other models.
Is there something already on the burner for a formula builder where, at the
very least, provide available models and their attributes for use in
calculating a value modification or a WHEN expression? I see there is an
'expression builder', but that seems to only handle explicit 'field'
{equal|greater|less|not equal} 'field', where I'm looking for a editor pane
(kind of a like a sql builder) where you can see the available models and
fields.
This would also be useful here, but this has to do with web decision tables
and adding the ability to take formulas in their Action:
https://issues.jboss.org/browse/GUVNOR-1596
thanks for any feedback,
-Darren
--
View this message in context: http://drools.46999.n3.nabble.com/guvnor-Formula-builder-or-freeform-drl-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
A small doubt
by Manohar Kokkula
Hi
I am new to drools and going through its documentation on the website. I
have installed Drools - Expert and Guvnor (BRMS). My question is : Is
Drools Guvnor also a rule engine or do we use Guvnor just to manage the
rules, packages etc. How does Guvnor link with the Drools Rule Engine.
Thanks & Regards,
Manohar
Mailto: manohar.kokkula(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
13 years, 3 months
declaring attributes for an existing class
by Neel
Hi,I've following class defined:public class User {
private String id;
//get,set, equals & hashCode method are defined
}
If I add more attributes using declare syntax as below:declare User name : Stringend
it gives error "Error creating field accessors for 'User' for type 'User'". Is there a way, more attributes can be added in existing class using declare syntax?
Alternatively, if a class is created by using only declare syntax, can we add equals/hasCode methods dynamically?
Thanks & Regards,Neel
13 years, 3 months
source of activity listener log entries
by lhorton
In my application that drives the rules engine, I have created my own
SystemEventListener that writes to my application log4j log file. I also
have also created my own AgendaEventListener to log to log4j, and have added
it to my stateless knowledge sessions. This is working fine and the
expected log entries show up in the correct application log.
However, there are also things being logged to my tomcat server log
(catalina.out). The entries look like this:
ACTIVATION CREATED rule:JobWorkflowRepeat activationId:JobWorkflowRepeat [2]
declarations: $daemon=Thread[Thread-29,5,main](2)
OBJECT ASSERTED value:Thread[Thread-29,5,main] factId: 2
BEFORE ACTIVATION FIRED rule:JobWorkflowRepeat
activationId:JobWorkflowRepeat [2] declarations:
$daemon=Thread[Thread-29,5,main](2)
AFTER ACTIVATION FIRED rule:JobWorkflowRepeat activationId:JobWorkflowRepeat
[2] declarations: $daemon=Thread[Thread-29,5,main](2)
I would like to get control over these log entries, to suppress some and to
route others to my application log. Where are these coming from? I have
not explicitly set up any listeners other than the ones I specified above.
I don't remember seeing these entries before 5.2.0.
thanks for any advice.
--
View this message in context: http://drools.46999.n3.nabble.com/source-of-activity-listener-log-entries...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
drools error: Unable to create restriction
by sam
I am getting the following error when running a drl script:
Unable to create restriction '[QualifiedIndentifierRestr:
Anyone can throw more light on what the issue is?
Here is my complete test set up:
public class InnerBean {
private int testVal = 100;
public int getTestVal() {
return testVal;
}
public void setTestVal(int testVal) {
this.testVal = testVal;
}
}
public class ValidationBean {
private int actualTestVal = 200;
private InnerBean innerBean= new InnerBean ();
public int getActualTestVal() {
return actualTestVal;
}
public void setActualTestVal(int actualTestVal) {
this.actualTestVal = actualTestVal;
}
public InnerBean getInnerBeanl() {
return innerBean;
}
public void setInnerBeanl(InnerBean argInnerBean) {
innerBean = argInnerBean;
}
}
The drl script is
package droolsbook.dsl;
import com.wellsfargo.mortgage.camr.model.hibernate.*;
import com.wellsfargo.mortgage.camr.model.service.drools.*;
rule "Threshold rule 1"
when
$bean: ValidationBean ( actualTestVal > innerBean.testVal )
then
--failure
end
The ValidationBean ($bean) is inserted into drools working memory.
Thanks in advance
Sam
--
View this message in context: http://drools.46999.n3.nabble.com/drools-error-Unable-to-create-restricti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Unable to create restriction error
by sam
I am getting the following error when running a drl script:
Unable to create restriction '[QualifiedIndentifierRestr:
Anyone can throw more light on what the issue is?
Here is my complete test set up:
public class InnerBean {
private int testVal = 100;
public int getTestVal() {
return testVal;
}
public void setTestVal(int testVal) {
this.testVal = testVal;
}
}
public class ValidationBean {
private int actualTestVal = 200;
private InnerBean innerBean= new InnerBean ();
public int getActualTestVal() {
return actualTestVal;
}
public void setActualTestVal(int actualTestVal) {
this.actualTestVal = actualTestVal;
}
public InnerBean getInnerBeanl() {
return innerBean;
}
public void setInnerBeanl(InnerBean argInnerBean) {
innerBean = argInnerBean;
}
}
The drl script is
package droolsbook.dsl;
import com.wellsfargo.mortgage.camr.model.hibernate.*;
import com.wellsfargo.mortgage.camr.model.service.drools.*;
rule "Threshold rule 1"
when
$bean: ValidationBean ( actualTestVal > innerBean.testVal )
then
--failure
end
The ValidationBean ($bean) is inserted into drools working memory.
Thanks in advance
Sam
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-create-restriction-error-tp32...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months