<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:sans-serif;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
tt
        {font-family:"Courier New";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>That’s actually my ticket, and I’ve
been hoping to get it resolved for awhile now. I’ve posted to this
mailing list as well as the actual ticket but haven’t heard responses
from anyone.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I’ve recently done more research
into the issue, and have some updated information that needs to be attached to
the ticket (I’ll try to get it in shortly) but what it boils down to is a
collision of two problems…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Problem 1: DSL and DSLR need to be in the
same folder, but if you don’t explicitly list the resources for each item
in the changeset, you can’t define an independent resource type. This
is kind of silly and in my mind defeats the benefits of the change-set. The
benefit in my mind of a change set is being able to point it at a folder and
have it scan for new rule additions as well as changes. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Problem 2: Internally the identified
resources in the change set are held in a hashmap. Since there’s no
ordering to a hashmap, when they’re pulled out and added to the
knowledgebuilder they could be added in any order. In order for a DSL and DSLR
to work, they have to be added to the KnowledgeBuilder in the proper order (DSL
first then DSLR). It does not matter what order you list them in the change
set, the rebuild code in the KnowledgeAgent framework does not enforce any
concept of ordering or priority to resource types.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>The documentation (since 5.0.1) has
suggested that at some point they plan to have “autodetection” of
file types which would solve for problem #1, but problem #2 would remain
without some priority given to how the KnowledgeBuilder is being instructed to
construct rule sets. This problem is present even in the latest 5.1 milestone.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Unfortunately this has driven us to choose
between having a DSL or having hot deployment of rules (we’ve chosen the
later)<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><st1:place w:st="on"><st1:City w:st="on"><font size=2
color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'>Macon</span></font></st1:City></st1:place><font size=2
color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Steve Ronderos<br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, January 26, 2010
2:58 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Rules Users List<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [rules-users]
KnowledgeAgent doesn't load dsl files and dslr file from a change-set correctly</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
</span></font><font size=2 face=sans-serif><span style='font-size:10.0pt;
font-family:sans-serif'>Pritham,</span></font> <br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>I've
experienced this issue before as well. It has to do with the way that the
KnowledgeAgent subscribes to resources. I believe behind the scenes the
resources are loaded in an arbitrary order. There is a JIRA bug report
already filed:</span></font> <br>
<br>
<a href="https://jira.jboss.org/jira/browse/JBRULES-2377"><font size=2
face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>https://jira.jboss.org/jira/browse/JBRULES-2377</span></font></a>
<br>
<br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'>Hope
this helps,</span></font> <br>
<font size=2 face=sans-serif><span style='font-size:10.0pt;font-family:sans-serif'><br>
</span></font>Steve <br>
<br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>rules-users-bounces@lists.jboss.org
wrote on 01/26/2010 01:07:29 PM:</span></font></tt><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<br>
<tt><font face="Courier New">> [image removed] </font></tt></span></font><br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> [rules-users] KnowledgeAgent doesn't load dsl
files and dslr file </font></tt><br>
<tt><font face="Courier New">> from a change-set correctly</font></tt></span></font>
<br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> Pritham </font></tt></span></font><br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> to:</font></tt></span></font> <br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> rules-users</font></tt></span></font> <br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> 01/26/2010 01:10 PM</font></tt></span></font>
<br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> Sent by:</font></tt></span></font> <br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> rules-users-bounces@lists.jboss.org</font></tt></span></font>
<br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> Please respond to Rules Users List</font></tt></span></font>
<br>
<tt><font size=2 face="Courier New"><span style='font-size:10.0pt'>> </span></font></tt><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> I have a folder in classpath:</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> dsl/global.dsl</font></tt><br>
<tt><font face="Courier New">> rules/section-A.dslr</font></tt><br>
<tt><font face="Courier New">> rules/section-A/page-1.dslr</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> I create a knowledge base like this:</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> public KnowledgeBase createKnowledgeBase()
throws DroolsParserException,</font></tt><br>
<tt><font face="Courier New">> IOException {</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> KnowledgeBuilder
knowledgeBuilder = KnowledgeBuilderFactory</font></tt><br>
<tt><font face="Courier New">>
.newKnowledgeBuilder();</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">>
knowledgeBuilder.add(ResourceFactory</font></tt><br>
<tt><font face="Courier New">>
.newClassPathResource("dsl/global.dsl"),</font></tt><br>
<tt><font face="Courier New">>
ResourceType.DSL);</font></tt><br>
<tt><font face="Courier New">>
knowledgeBuilder.add(ResourceFactory</font></tt><br>
<tt><font face="Courier New">>
.newClassPathResource("rules/section-A.dslr"),</font></tt><br>
<tt><font face="Courier New">>
ResourceType.DSLR);</font></tt><br>
<tt><font face="Courier New">>
knowledgeBuilder.add(ResourceFactory</font></tt><br>
<tt><font face="Courier New">>
.newClassPathResource("rules/section-A/page-1.dslr"),</font></tt><br>
<tt><font face="Courier New">>
ResourceType.DSLR); </font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> if
(knowledgeBuilder.hasErrors()) {</font></tt><br>
<tt><font face="Courier New">> throw new
RuntimeException(knowledgeBuilder.getErrors().toString());</font></tt><br>
<tt><font face="Courier New">> }</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase();</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">>
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> return knowledgeBase;</font></tt><br>
<tt><font face="Courier New">> }</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> // code</font></tt><br>
<tt><font face="Courier New">> knowledgeBase = createKnowledgeBase();</font></tt><br>
<tt><font face="Courier New">> session =
knowledgeBase.newStatefulKnowledgeSession();</font></tt><br>
<tt><font face="Courier New">> // insert facts</font></tt><br>
<tt><font face="Courier New">> session.fireAllRules();</font></tt><br>
<tt><font face="Courier New">> session.dispose(); </font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> The above code works and I can get a unit
test to work that processes rules</font></tt><br>
<tt><font face="Courier New">> accordingly. I can see my dslr converting to
a drl using the "drl viewer"</font></tt><br>
<tt><font face="Courier New">> correctly (provided I temporarily place the
dsl file in the same location</font></tt><br>
<tt><font face="Courier New">> since expander doesn't accept a relative
path).</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> The problem, however is when I use a
change-set.xml and a KnowledgeAgent,</font></tt><br>
<tt><font face="Courier New">> things don't work </font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> code for loading via knowledgeAgent</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> public static KnowledgeBase
loadKnowledgeBase() throws</font></tt><br>
<tt><font face="Courier New">> DroolsParserException, IOException {</font></tt><br>
<tt><font face="Courier New">> agent =
KnowledgeAgentFactory.newKnowledgeAgent("msll agent");</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">>
agent.applyChangeSet(ResourceFactory.newClassPathResource("change-set.xml"));</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> return
agent.getKnowledgeBase();</font></tt><br>
<tt><font face="Courier New">> } </font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> <change-set
xmlns='http://drools.org/drools-5.0/change-set'</font></tt><br>
<tt><font face="Courier New">>
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'</font></tt><br>
<tt><font face="Courier New">>
xs:schemaLocation='http://drools.org/drools-5.0/change-set.xsd'</font></tt><br>
<tt><font face="Courier New">> ></font></tt><br>
<tt><font face="Courier New">> <add></font></tt><br>
<tt><font face="Courier New">> <resource
source='classpath:dsl/' type='DSL' /> </font></tt><br>
<tt><font face="Courier New">> <resource
source='classpath:rules/' type='DSLR' /> </font></tt><br>
<tt><font face="Courier New">> <resource
source='classpath:rules/section-A/' type='DSLR' /></font></tt><br>
<tt><font face="Courier New">> </add></font></tt><br>
<tt><font face="Courier New">> </change-set></font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> I get the following generic drools errors:</font></tt><br>
<tt><font face="Courier New">> ERR 103] Line 4:0 rule 'rule_key' failed
predicate:</font></tt><br>
<tt><font face="Courier New">> {(validateIdentifierKey(DroolsSoftKeywords.RULE))}?
in rule[7,0]: [ERR 101]</font></tt><br>
<tt><font face="Courier New">> Line 7:0 no viable alternative at input
'import' in rule Con in rule</font></tt><br>
<tt><font face="Courier New">> attribute</font></tt><br>
<tt><font face="Courier New">> ...</font></tt><br>
<tt><font face="Courier New">> ...</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> The rules are same, folder location is the
same. I believe that drools has a</font></tt><br>
<tt><font face="Courier New">> problem resolving path (expander global.dsl)
from the dslr file when using a</font></tt><br>
<tt><font face="Courier New">> KnowlegeAgent since in the earlier strategy,
one could build a dsl into the</font></tt><br>
<tt><font face="Courier New">> knowledgeBuilder directly from the classpath.</font></tt><br>
<tt><font face="Courier New">> </font></tt><br>
<tt><font face="Courier New">> Pl suggest.</font></tt><br>
<tt><font face="Courier New">> -- </font></tt><br>
<tt><font face="Courier New">> View this message in context: </font></tt></span></font><a
href="http://n3.nabble.com/KnowledgeAgent-"><tt><font size=2 face="Courier New"><span
style='font-size:10.0pt'>http://n3.nabble.com/KnowledgeAgent-</span></font></tt></a><font
size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'><br>
<tt><font face="Courier New">>
doesn-t-load-dsl-files-and-dslr-file-from-a-change-set-correctly-</font></tt><br>
<tt><font face="Courier New">> tp139702p139702.html</font></tt><br>
<tt><font face="Courier New">> Sent from the Drools - User mailing list
archive at Nabble.com.</font></tt><br>
<tt><font face="Courier New">> _______________________________________________</font></tt><br>
<tt><font face="Courier New">> rules-users mailing list</font></tt><br>
<tt><font face="Courier New">> rules-users@lists.jboss.org</font></tt><br>
<tt><font face="Courier New">> </font></tt></span></font><a
href="https://lists.jboss.org/mailman/listinfo/rules-users"><tt><font size=2
face="Courier New"><span style='font-size:10.0pt'>https://lists.jboss.org/mailman/listinfo/rules-users</span></font></tt></a><o:p></o:p></p>
</div>
</body>
</html>