[rules-users] Facing Problem in BRL

Wolfgang Laun wolfgang.laun at gmail.com
Wed May 18 06:09:01 EDT 2011


2011/5/18 Michael Anstis <michael.anstis at gmail.com>

> I just checked and when I create a new BRL rule drools.packages has the
> comment on a single line.
>
>
od -tx1 bfzwork/aws/src/main/rules/drools.package
0000000 2f 2f 54 68 69 73 20 69 73 20 61 20 70 61 63 6b
0000020 61 67 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f
0000040 6e 20 66 69 6c 65 *0a* 2f 2f 41 64 64 20 69 6d 70
0000060 6f 72 74 73 2c 20 67 6c 6f 62 61 6c 73 20 65 74
0000100 63 20 68 65 72 65 20 77 68 69 63 68 20 77 69 6c
0000120 6c 20 62 65 20 75 73 65 64 20 62 79 20 61 6c 6c
0000140 20 74 68 65 20 72 75 6c 65 20 61 73 73 65 74 73
0000160 20 69 6e 20 74 68 69 73 20 66 6f 6c 64 65 72 2e
0000200

The second and last line has no trailing LF.
-W






> I must assume there was some manual change made to introduce the error.
>
> 2011/5/18 Wolfgang Laun <wolfgang.laun at gmail.com>
>
>> There is some code in 5.1.1
>> org/drools/eclipse/rulebuilder/editors/RuleEditor.java
>> that creates a file "drools.package" with
>>
>>      if ( !file.exists() ) {
>>                     String defaultHeader = "//This is a package
>> configuration file";
>>                     defaultHeader += "\n//Add imports, globals etc here
>> which will be used by all the rule assets in this folder.";
>>                     InputStream is = new ByteArrayInputStream(
>> defaultHeader.getBytes() );
>>
>> Note the missing newline at the end of defaultHeader.
>>
>> -W
>>
>>
>>
>> 2011/5/18 Michael Anstis <michael.anstis at gmail.com>
>>
>>> //Add imports, globals etc here which will be used by all the rule assets
>>>  in this folder.
>>>
>>> should be on one line, or add another comment marker at the start of the
>>> second line, e.g.:-
>>>
>>>
>>> //Add imports, globals etc here which will be used by all the rule assets
>>> in this folder.
>>>
>>> //Add imports, globals etc here which will be used by all the rule assets
>>> // in this folder.
>>>
>>> 2011/5/18 Abhay B. Chaware <Abhay.Chaware at kpitcummins.com>
>>>
>>>  I was able to reproduce your error … J  try adding a new line ( enter )
>>>> after the comment in the  drools.package …. Or just remove the commented
>>>> line “//Add imports, globals etc here which will be used by all the
>>>> rule assets in this folder.”
>>>>
>>>>
>>>>
>>>> Your rule name is getting ‘commented out’ ………
>>>>
>>>>
>>>>
>>>> -abhay
>>>>
>>>> *-----------------------*
>>>>
>>>> * *
>>>>
>>>> * *
>>>>
>>>> * *
>>>>
>>>> *From:* rules-users-bounces at lists.jboss.org [mailto:
>>>> rules-users-bounces at lists.jboss.org] *On Behalf Of *Michael Anstis
>>>> *Sent:* Wednesday, May 18, 2011 2:53 PM
>>>>
>>>> *To:* Rules Users List
>>>> *Subject:* Re: [rules-users] Facing Problem in BRL
>>>>
>>>>
>>>>
>>>> This looks rogue:-
>>>>
>>>> //Add imports, globals etc here which will be used by all the rule
>>>> assets
>>>> in this folder
>>>>
>>>> Can you post the content of your drools.packages file?
>>>>
>>>> On 18 May 2011 10:19, Sumeet Karawal <sumeet.karawal at tcs.com> wrote:
>>>>
>>>> This is the output that I get :
>>>>
>>>> //This is a package configuration file
>>>>
>>>> package com.rules;
>>>>
>>>> import com.model.PersonDetails;
>>>>
>>>> //Add imports, globals etc here which will be used by all the rule
>>>> assets
>>>> in this folder.rule "example"
>>>>        dialect "mvel"
>>>>        when
>>>>                $person : PersonDetails( age < "20" )
>>>>
>>>>        then
>>>>                $person.setDiscount( 10 );
>>>> end
>>>>
>>>> java.lang.RuntimeException: [8,1]: [ERR 102] Line 8:1 mismatched input
>>>> 'WHEN'
>>>>
>>>>   Regards,
>>>> Sumeet Karawal
>>>> Mailto: sumeet.karawal at tcs.com
>>>>
>>>>
>>>>
>>>>  From:       "Abhay B. Chaware" <Abhay.Chaware at kpitcummins.com>
>>>>
>>>>  To:         Rules Users List <rules-users at lists.jboss.org>
>>>>
>>>>  Date:       05/18/2011 02:47 PM
>>>>
>>>>
>>>>  Subject:    Re: [rules-users] Facing Problem in BRL
>>>>
>>>>  Sent by:    rules-users-bounces at lists.jboss.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Can you write the outputDRL to System.out and check if the generated DRL
>>>> syntax is correct ?
>>>>
>>>> System.out.println(outputDRL);
>>>>
>>>> Before instantiating KnowledgeBuilder
>>>>
>>>>
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: rules-users-bounces at lists.jboss.org [
>>>> mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Sumeet Karawal
>>>> Sent: Wednesday, May 18, 2011 2:42 PM
>>>> To: Rules Users List
>>>> Subject: Re: [rules-users] Facing Problem in BRL
>>>>
>>>> I tried to use this also but now I am getting different error:
>>>> java.lang.RuntimeException: [8,1]: [ERR 102] Line 8:1 mismatched input
>>>> 'WHEN'
>>>>
>>>>
>>>> Also, what is the significance of the first line. I have copied it as
>>>> the
>>>> same.
>>>>
>>>> My code is :
>>>>
>>>>      String curDir = System.getProperty("user.dir");
>>>>                 String fileName = curDir + "\\src\\com\\rules
>>>> \\drools.package";
>>>>                 String rulePackageContent =
>>>> FileUtils.readFileToString(new
>>>> File
>>>> (fileName));
>>>>                 fileName = curDir + "\\src\\com\\rules\\example.brl";
>>>>                 String brl = FileUtils.readFileToString(new
>>>> File(fileName));
>>>>                 BRLPersistence read = BRXMLPersistence.getInstance();
>>>>                 BRLPersistence write = BRDRLPersistence.getInstance();
>>>>                 String outputDRL = rulePackageContent + write.marshal
>>>> (read.unmarshal
>>>> (brl));
>>>>                 KnowledgeBuilder builder = KnowledgeBuilderFactory.
>>>> newKnowledgeBuilder();
>>>>                 builder.add(ResourceFactory.newReaderResource(new
>>>> StringReader
>>>> (outputDRL)), ResourceType.DRL);
>>>>
>>>>
>>>>    if (builder.hasErrors()) {
>>>>      throw new RuntimeException (builder.getErrors().toString ());
>>>>    }
>>>>    KnowledgeBase knowledgeBase =
>>>> KnowledgeBaseFactory.newKnowledgeBase();
>>>>    knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages ());
>>>>
>>>> I don't know where I am getting this wrong.
>>>>
>>>> Regards,
>>>> Sumeet Karawal
>>>> Mailto: sumeet.karawal at tcs.com
>>>>
>>>>
>>>>
>>>>  From:       "Abhay B. Chaware" <Abhay.Chaware at kpitcummins.com>
>>>>
>>>>
>>>>  To:         Rules Users List <rules-users at lists.jboss.org>
>>>>
>>>>
>>>>  Date:       05/18/2011 01:09 PM
>>>>
>>>>
>>>>  Subject:    Re: [rules-users] Facing Problem in BRL
>>>>
>>>>
>>>>  Sent by:    rules-users-bounces at lists.jboss.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> I haven't been able to get "ResourceType.BRL" to work. This is how I do
>>>> it ..
>>>>
>>>> String curDir = System.getProperty("user.dir");
>>>> String fileName = curDir + "\\src\\main\\rules\\drools.package";
>>>> String rulePackageContent = FileUtils.readFileToString(new
>>>> File(fileName));
>>>>
>>>> fileName = curDir + "\\src\\main\\rules\\eligibility.brl";
>>>> String brl = FileUtils.readFileToString(new File(fileName));
>>>> BRLPersistence read = BRXMLPersistence.getInstance();
>>>> BRLPersistence write = BRDRLPersistence.getInstance();
>>>> String outputDRL = rulePackageContent +
>>>> write.marshal(read.unmarshal(brl));
>>>>
>>>> KnowledgeBuilder kbuilder =
>>>> KnowledgeBuilderFactory.newKnowledgeBuilder();
>>>> kbuilder.add(ResourceFactory.newReaderResource(new StringReader
>>>> (outputDRL)), ResourceType.DRL);
>>>>
>>>>
>>>> Try this.
>>>>
>>>>
>>>> -abhay
>>>>
>>>> -----Original Message-----
>>>> From: rules-users-bounces at lists.jboss.org [
>>>> mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Sumeet Karawal
>>>> Sent: Wednesday, May 18, 2011 11:47 AM
>>>> To: Rules Users List
>>>> Subject: Re: [rules-users] Facing Problem in BRL
>>>>
>>>> This is the brl that I have created:
>>>>
>>>>
>>>> (Embedded image moved to file: pic18001.jpg)
>>>>
>>>>
>>>> Regards,
>>>> Sumeet Karawal
>>>> Mailto: sumeet.karawal at tcs.com
>>>>
>>>>
>>>>
>>>>  From:       "Abhay B. Chaware" <Abhay.Chaware at kpitcummins.com>
>>>>
>>>>
>>>>  To:         Rules Users List <rules-users at lists.jboss.org>
>>>>
>>>>
>>>>  Date:       05/18/2011 11:42 AM
>>>>
>>>>
>>>>  Subject:    Re: [rules-users] Facing Problem in BRL
>>>>
>>>>
>>>>  Sent by:    rules-users-bounces at lists.jboss.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Could you post your rule content here ?
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: rules-users-bounces at lists.jboss.org [
>>>> mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Sumeet Karawal
>>>> Sent: Wednesday, May 18, 2011 11:38 AM
>>>> To: rules-users at lists.jboss.org
>>>> Subject: [rules-users] Facing Problem in BRL
>>>>
>>>>
>>>> Hi,
>>>>
>>>> I am using Drools-Expert. I am having a class "Person" with data members
>>>> as
>>>> age and discount.
>>>> I am trying to create a .brl. I have these statements in drools.package
>>>> package com.rules;
>>>>
>>>> import com.model.PersonDetails;
>>>>
>>>>
>>>> and in the example.brl I am providing the details of when and then
>>>> conditions
>>>>
>>>> but on execution I am getting the following error :
>>>>
>>>> java.lang.RuntimeException: [4] Unable to expand: PersonDetails( age <
>>>> "20" )[6] Unable to expand:
>>>> PersonDetails fact0 = new
>>>> PersonDetails
>>>> ();[7] Unable to expand:
>>>> fact0.setDiscount
>>>> ( 10 );[8] Unable to
>>>> expand:
>>>>                                   insert(fact0 );
>>>>
>>>>
>>>> It would be helpful is somebody guide me on how execute it.
>>>>
>>>> Also, I am creating the knowledgebase as:
>>>>
>>>> private static KnowledgeBase createKnowledgeBase() {
>>>>  KnowledgeBuilder builder =
>>>> KnowledgeBuilderFactory.newKnowledgeBuilder();
>>>>    builder.add (ResourceFactory.newClassPathResource(
>>>> "com/rules/example.brl"),ResourceType.BRL);
>>>>    if (builder.hasErrors()) {
>>>>      throw new RuntimeException (builder.getErrors().toString ());
>>>>    }
>>>>    KnowledgeBase knowledgeBase =
>>>> KnowledgeBaseFactory.newKnowledgeBase();
>>>>    knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages ());
>>>>    return knowledgeBase;}
>>>>
>>>>
>>>> Thanks & Regards,
>>>> Sumeet Karawal
>>>> CEG - Open Source Technology Group
>>>> Tata Consultancy Services
>>>> Ph:- +912267782556
>>>> Cell:- +919833236440
>>>> Mailto: sumeet.karawal at tcs.com
>>>> Website: http://www.tcs.com
>>>> ____________________________________________
>>>> Experience certainty.
>>>>            IT
>>>> Services
>>>>
>>>> Business Solutions
>>>>
>>>> Outsourcing
>>>> ____________________________________________
>>>>
>>>> =====-----=====-----=====
>>>> 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
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>> =====-----=====-----=====
>>>> 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
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>>> =====-----=====-----=====
>>>> 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
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>>> =====-----=====-----=====
>>>> 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
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>>> This message contains information that may be privileged or confidential
>>>> and is the property of the KPIT Cummins Infosystems Ltd. It is intended only
>>>> for the person to whom it is addressed. If you are not the intended
>>>> recipient, you are not authorized to read, print, retain copy, disseminate,
>>>> distribute, or use this message or any part thereof. If you receive this
>>>> message in error, please notify the sender immediately and delete all copies
>>>> of this message. KPIT Cummins Infosystems Ltd. does not accept any liability
>>>> for virus infected mails.
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110518/6d76c005/attachment.html 


More information about the rules-users mailing list