This looks rogue:-<br><br>//Add imports, globals etc here which will be used by all the rule assets<br>
in this folder<br><br>Can you post the content of your drools.packages file?<br><br><div class="gmail_quote">On 18 May 2011 10:19, Sumeet Karawal <span dir="ltr"><<a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">This is the output that I get :<br>
<br>
//This is a package configuration file<br>
<div class="im">package com.rules;<br>
<br>
import com.model.PersonDetails;<br>
<br>
</div>//Add imports, globals etc here which will be used by all the rule assets<br>
in this folder.rule "example"<br>
dialect "mvel"<br>
when<br>
$person : PersonDetails( age < "20" )<br>
<div class="im"> then<br>
$person.setDiscount( 10 );<br>
end<br>
<br>
</div><div class="im">java.lang.RuntimeException: [8,1]: [ERR 102] Line 8:1 mismatched input<br>
'WHEN'<br>
<br>
<br>
</div><div class="im">Regards,<br>
Sumeet Karawal<br>
Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
<br>
<br>
<br>
From: "Abhay B. Chaware" <<a href="mailto:Abhay.Chaware@kpitcummins.com">Abhay.Chaware@kpitcummins.com</a>><br>
<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
<br>
</div> Date: 05/18/2011 02:47 PM<br>
<div><div></div><div class="h5"><br>
Subject: Re: [rules-users] Facing Problem in BRL<br>
<br>
Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
Can you write the outputDRL to System.out and check if the generated DRL<br>
syntax is correct ?<br>
<br>
System.out.println(outputDRL);<br>
<br>
Before instantiating KnowledgeBuilder<br>
<br>
<br>
<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [<br>
mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Sumeet Karawal<br>
Sent: Wednesday, May 18, 2011 2:42 PM<br>
To: Rules Users List<br>
Subject: Re: [rules-users] Facing Problem in BRL<br>
<br>
I tried to use this also but now I am getting different error:<br>
java.lang.RuntimeException: [8,1]: [ERR 102] Line 8:1 mismatched input<br>
'WHEN'<br>
<br>
<br>
Also, what is the significance of the first line. I have copied it as the<br>
same.<br>
<br>
My code is :<br>
<br>
String curDir = System.getProperty("user.dir");<br>
String fileName = curDir + "\\src\\com\\rules<br>
\\drools.package";<br>
String rulePackageContent = FileUtils.readFileToString(new<br>
File<br>
(fileName));<br>
fileName = curDir + "\\src\\com\\rules\\example.brl";<br>
String brl = FileUtils.readFileToString(new File(fileName));<br>
BRLPersistence read = BRXMLPersistence.getInstance();<br>
BRLPersistence write = BRDRLPersistence.getInstance();<br>
String outputDRL = rulePackageContent + write.marshal<br>
(read.unmarshal<br>
(brl));<br>
KnowledgeBuilder builder = KnowledgeBuilderFactory.<br>
newKnowledgeBuilder();<br>
builder.add(ResourceFactory.newReaderResource(new StringReader<br>
(outputDRL)), ResourceType.DRL);<br>
<br>
<br>
if (builder.hasErrors()) {<br>
throw new RuntimeException (builder.getErrors().toString ());<br>
}<br>
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();<br>
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages ());<br>
<br>
I don't know where I am getting this wrong.<br>
<br>
Regards,<br>
Sumeet Karawal<br>
Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
<br>
<br>
<br>
From: "Abhay B. Chaware" <<a href="mailto:Abhay.Chaware@kpitcummins.com">Abhay.Chaware@kpitcummins.com</a>><br>
<br>
<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
<br>
<br>
Date: 05/18/2011 01:09 PM<br>
<br>
<br>
Subject: Re: [rules-users] Facing Problem in BRL<br>
<br>
<br>
Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
I haven't been able to get "ResourceType.BRL" to work. This is how I do<br>
it ..<br>
<br>
String curDir = System.getProperty("user.dir");<br>
String fileName = curDir + "\\src\\main\\rules\\drools.package";<br>
String rulePackageContent = FileUtils.readFileToString(new File(fileName));<br>
<br>
fileName = curDir + "\\src\\main\\rules\\eligibility.brl";<br>
String brl = FileUtils.readFileToString(new File(fileName));<br>
BRLPersistence read = BRXMLPersistence.getInstance();<br>
BRLPersistence write = BRDRLPersistence.getInstance();<br>
String outputDRL = rulePackageContent + write.marshal(read.unmarshal(brl));<br>
<br>
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
kbuilder.add(ResourceFactory.newReaderResource(new StringReader<br>
(outputDRL)), ResourceType.DRL);<br>
<br>
<br>
Try this.<br>
<br>
<br>
-abhay<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [<br>
mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Sumeet Karawal<br>
Sent: Wednesday, May 18, 2011 11:47 AM<br>
To: Rules Users List<br>
Subject: Re: [rules-users] Facing Problem in BRL<br>
<br>
This is the brl that I have created:<br>
<br>
<br>
(Embedded image moved to file: pic18001.jpg)<br>
<br>
<br>
Regards,<br>
Sumeet Karawal<br>
Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
<br>
<br>
<br>
From: "Abhay B. Chaware" <<a href="mailto:Abhay.Chaware@kpitcummins.com">Abhay.Chaware@kpitcummins.com</a>><br>
<br>
<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
<br>
<br>
Date: 05/18/2011 11:42 AM<br>
<br>
<br>
Subject: Re: [rules-users] Facing Problem in BRL<br>
<br>
<br>
Sent by: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Could you post your rule content here ?<br>
<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [<br>
mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Sumeet Karawal<br>
Sent: Wednesday, May 18, 2011 11:38 AM<br>
To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
Subject: [rules-users] Facing Problem in BRL<br>
<br>
<br>
Hi,<br>
<br>
I am using Drools-Expert. I am having a class "Person" with data members as<br>
age and discount.<br>
I am trying to create a .brl. I have these statements in drools.package<br>
package com.rules;<br>
<br>
import com.model.PersonDetails;<br>
<br>
<br>
and in the example.brl I am providing the details of when and then<br>
conditions<br>
<br>
but on execution I am getting the following error :<br>
<br>
java.lang.RuntimeException: [4] Unable to expand: PersonDetails( age <<br>
"20" )[6] Unable to expand:<br>
PersonDetails fact0 = new<br>
PersonDetails<br>
();[7] Unable to expand:<br>
fact0.setDiscount<br>
( 10 );[8] Unable to<br>
expand:<br>
insert(fact0 );<br>
<br>
<br>
It would be helpful is somebody guide me on how execute it.<br>
<br>
Also, I am creating the knowledgebase as:<br>
<br>
private static KnowledgeBase createKnowledgeBase() {<br>
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
builder.add (ResourceFactory.newClassPathResource(<br>
"com/rules/example.brl"),ResourceType.BRL);<br>
if (builder.hasErrors()) {<br>
throw new RuntimeException (builder.getErrors().toString ());<br>
}<br>
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();<br>
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages ());<br>
return knowledgeBase;}<br>
<br>
<br>
Thanks & Regards,<br>
Sumeet Karawal<br>
CEG - Open Source Technology Group<br>
Tata Consultancy Services<br>
Ph:- +912267782556<br>
Cell:- +919833236440<br>
Mailto: <a href="mailto:sumeet.karawal@tcs.com">sumeet.karawal@tcs.com</a><br>
Website: <a href="http://www.tcs.com" target="_blank">http://www.tcs.com</a><br>
____________________________________________<br>
Experience certainty. IT<br>
Services<br>
<br>
Business Solutions<br>
<br>
Outsourcing<br>
____________________________________________<br>
<br>
=====-----=====-----=====<br>
Notice: The information contained in this e-mail<br>
message and/or attachments to it may contain<br>
confidential or privileged information. If you are<br>
not the intended recipient, any dissemination, use,<br>
review, distribution, printing or copying of the<br>
information contained in this e-mail message<br>
and/or attachments to it are strictly prohibited. If<br>
you have received this communication in error,<br>
please notify us by reply e-mail or telephone and<br>
immediately and permanently delete the message<br>
and any attachments. Thank you<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
=====-----=====-----=====<br>
Notice: The information contained in this e-mail<br>
message and/or attachments to it may contain<br>
confidential or privileged information. If you are<br>
not the intended recipient, any dissemination, use,<br>
review, distribution, printing or copying of the<br>
information contained in this e-mail message<br>
and/or attachments to it are strictly prohibited. If<br>
you have received this communication in error,<br>
please notify us by reply e-mail or telephone and<br>
immediately and permanently delete the message<br>
and any attachments. Thank you<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
=====-----=====-----=====<br>
Notice: The information contained in this e-mail<br>
message and/or attachments to it may contain<br>
confidential or privileged information. If you are<br>
not the intended recipient, any dissemination, use,<br>
review, distribution, printing or copying of the<br>
information contained in this e-mail message<br>
and/or attachments to it are strictly prohibited. If<br>
you have received this communication in error,<br>
please notify us by reply e-mail or telephone and<br>
immediately and permanently delete the message<br>
and any attachments. Thank you<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
=====-----=====-----=====<br>
Notice: The information contained in this e-mail<br>
message and/or attachments to it may contain<br>
confidential or privileged information. If you are<br>
not the intended recipient, any dissemination, use,<br>
review, distribution, printing or copying of the<br>
information contained in this e-mail message<br>
and/or attachments to it are strictly prohibited. If<br>
you have received this communication in error,<br>
please notify us by reply e-mail or telephone and<br>
immediately and permanently delete the message<br>
and any attachments. Thank you<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>