This looks as if you inserted some object ServiceBean extends HashMap as a fact? Whatever for? Originally, this was class Service.<br><br>Make sure to distinguish template expansion from rule execution.<br><br>The former should result in a DRL file containing several rules (all with different names!).<br>
<br>-W<br><br><br><br><div class="gmail_quote">2011/6/1 ChrisMu <span dir="ltr">&lt;<a href="mailto:christopher.mullard@credit-suisse.com">christopher.mullard@credit-suisse.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">





<div dir="ltr" align="left"><span><font face="Arial" size="2" color="#0000ff">I get this exception:</font></span></div>
<div><font face="Arial" size="2" color="#0000ff">Exception in thread &quot;main&quot; 
org.drools.runtime.rule.ConsequenceException: rule: RFI1</font></div>
<div> </div>
<div><font face="Arial" size="2" color="#0000ff"> at 
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)<br> at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)<br> at 
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)<br> at 
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)<br> at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)<br> at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)<br> at 
org.drools.template.parser.TemplateDataListener.finishSheet(TemplateDataListener.java:121)<br> at 
org.drools.template.DataProviderCompiler.finishData(DataProviderCompiler.java:100)<br> at 
org.drools.template.DataProviderCompiler.processData(DataProviderCompiler.java:95)<br> at 
org.drools.template.DataProviderCompiler.compile(DataProviderCompiler.java:73)<br> at 
org.drools.template.ObjectDataCompiler.compile(ObjectDataCompiler.java:44)<br> at 
org.drools.examples.decisiontable.TemplateParser.&lt;init&gt;(TemplateParser.java:33)<br> at 
org.drools.examples.decisiontable.TemplateParser.main(TemplateParser.java:18)<br>Caused 
by: java.lang.RuntimeException: [Error: unable to resolve method: 
java.util.HashMap.value() [arglength=0]]<br>[Near : {... Unknown 
....}]<br>             
^<br>[Line: 1, Column: 0]<br> at 
org.drools.template.parser.DefaultGenerator.generate(DefaultGenerator.java:73)<br> at 
org.drools.template.parser.Rule_RFI1_0.defaultConsequence(Rule_RFI1_0.java:7)<br> at 
org.drools.template.parser.Rule_RFI1_0DefaultConsequenceInvoker.evaluate(Rule_RFI1_0DefaultConsequenceInvoker.java:30)<br> at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)<br> ... 
11 more<br>Caused by: [Error: unable to resolve method: 
java.util.HashMap.value() [arglength=0]]<br>[Near : {... Unknown 
....}]<br>             
^<br>[Line: 1, Column: 0]<br> at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:932)<br> at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:592)<br> at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:311)<br> at 
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:137)<br></font></div>
<div dir="ltr" align="left"><span><font face="Arial" size="2" color="#0000ff"></font></span> </div>
<div><span></span><font face="Arial" size="2" color="#0000ff">My rule template is virtually the same<span> (name is a literal)</span>:</font></div>
<div><font face="Arial" size="2" color="#0000ff">rule &quot;</font><a href="http://user/SendEmail.jtp?type=node&amp;node=3010031&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a><font face="Arial"><font color="#0000ff"><font size="2">}&quot;<br>
when <br> $service:ServiceBean(name == &quot;DiscountCurve&quot;, value 
== &quot;@{value}&quot;) <div class="im"><br> $riskType:RiskType()<br>then 
<br> $riskType.setName(&quot;@{type}&quot;);<br></div> $riskType.setValue(&quot;@{<span>value</span>}&quot;);<br>end template<span></span></font></font></font><br></div>
<div dir="ltr" lang="en-us" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> Wolfgang Laun-2 [via Drools] 
[mailto:<a href="http://user/SendEmail.jtp?type=node&amp;node=3010031&amp;i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>] <br><b>Sent:</b> 01 
June 2011 10:33<br><b>To:</b> Mullard, Christopher<br><b>Subject:</b> Re: 
[rules-users] Smart Templates<br></font><br></div><div class="im">
<div></div>There is a way, provided the required information is available at the 
time the rule is created.<br><br>There is a detailed section in the Expert 
manual explaining how to call template expansion with either a Collection of Map 
objects or a Collection of JavaBean objects. Taking beans, you would 
have<br><br>ServiceBean( String name, String value )<br>String getName<br>String 
getValue<br>String getType(){<br></div>   if( &quot;AAA&quot;.equals( value ) ) 
return &quot;Type1&quot;;<br>   if( &quot;XYZ&quot;.equals( value ) ) return 
&quot;Type2&quot;;<br>   ...<div class="im"><br>}<br><br>You create a collection of such 
Objects, and call the expander for a template like this:<br><br>rule 
&quot;DC_@{row.rowNumber}&quot; <br>when <br></div>  Â  $service: Service(name == 
&quot;@{service}&quot;, value == &quot;@{value}&quot;) <br>  Â  $riskType: RiskType() 
<br>then <br>  Â  $riskType.setName(&quot;@{type}&quot;); <br>
<div>  Â  $riskType.setAtt(0,&quot;@{value}&quot;); <br>end 
</div><br>-W<br><br><br><br>
<div class="gmail_quote">2011/6/1 ChrisMu <span dir="ltr">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=3009984&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 2px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding: 0px 1em;"><div class="im">
  <div dir="ltr" align="left"><span><font face="Arial" size="2" color="#0000ff">So in 
  essence, there&#39;s no way to use a function to insert a string literal into a 
  rule from a template?</font></span></div><br>
  <div dir="ltr" lang="en-us" align="left">
  <hr>
  <font face="Tahoma" size="2"><b>From:</b> FrankVhh [via Drools] [mailto:<a href="http://user/SendEmail.jtp?type=node&amp;node=3009838&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>] 
  <br><b>Sent:</b> 31 May 2011 17:20<br><b>To:</b> Mullard, 
  Christopher<br><b>Subject:</b> RE: Smart Templates<br></font><br></div>
  <div></div>But then that would call the service.getType() method when the rule 
  is <br>run wouldn&#39;t it? <br>-&gt; Yes <br></div>  <br><div class="im">I&#39;m trying create 
  explicit, simple rules to avoid doing extra work when <br>running data through 
  them. <br>-&gt; OK, in essence, I like that :-) <br></div>  <br><div class="im">How would you 
  use a rule to set the value within another rule? <br>-&gt; I am not sure that 
  I follow you here... <br>If you want to avoid to execute the getType()-service 
  at rule execution, then you would need to add an attribute name to your 
  object, and call getType() before creating the rules. <br><br>Alternatively, 
  you can insert an intermediate value whose value will be set by another rule 
  and then use this intermediate value in your DC rules. <br><br>When 
  <br>Service(value = &quot;AAA&quot;) <br>Then <br>String name = &quot;Type1&quot;; 
  <br>insert(name); <br><br>Something like this... but make sure not to create a 
  loop :-) <br><br>Regards, <br>Frank <br><br>
  </div><blockquote style="border-left: 2px solid rgb(204, 204, 204); padding: 0px 1em;">
    <div>
    <div style="font-weight: bold;">ChrisMu wrote:</div>
    <div><div class="im">But then that would call the service.getType() method when the rule is 
    <br>run wouldn&#39;t it? <br></div>  <br><div class="im">I&#39;m trying create explicit, simple 
    rules to avoid doing extra work when <br>running data through them. 
    <br></div>  <br><div class="im">How would you use a rule to set the value within another 
    rule? <br></div>  <br><div class="im">Thanks <br>Chris 
    <br><br>________________________________ <br><br>From: FrankVhh [via Drools] 
    <br>[mailto:<a href="http://user/SendEmail.jtp?type=node&amp;node=3006773&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>] <br>Sent: 31 
    May 2011 16:48 <br>To: Mullard, Christopher <br>Subject: Re: Smart Templates 
    <br><br><br>Hi, <br><br>The way I see it, this is the way your template 
    should look like. I do <br>not see the need to use eval() at all. 
    <br><br>rule &quot;DC_0&quot; <br>when <br></div>  Â  $service: Service(name == 
    &quot;@{service}&quot;, value == &quot;@{value}&quot;) <br>  Â  $riskType: RiskType() 
    <br>then <br>  Â  
    $riskType.setName($service.getType(&quot;@{value}&quot;)); <br>  Â  
    $riskType.setAtt(0,&quot;@{value}&quot;); <br><div class="im">end <br><br>I am assuming that RiskType 
    is already inserted in WM, but you could <br>just as well create a new 
    object in the then-part of the rule. <br><br>In stead of using the 
    java-function to determine the name, you might <br>actually just as well 
    create an other rule that sets the name according <br>to the value, thus 
    putting the entire decision logic in rules. <br><br>Hope this helps. 
    <br><br>Regards, <br>Frank <br><br><br><br></div>  Â  Â  Â  
    ChrisMu wrote: <br>  Â  Â  Â  Hi, <br>  Â  
    Â  Â  <br>  Â  Â  Â  Â I&#39;m trying to get 
    a template (.drt) to generate 2 rules (.drl) <br><div class="im">from 2 datasets but by 
    doing a little bit more work than direct <br>substitution. <br></div>  
    Â  Â  Â  <br>  Â  Â  Â  Data 
    (service,value): <br>  Â  Â  Â  DC, AAA <br>  
    Â  Â  Â  DC, XYZ <br>  Â  Â  Â  
    <br>  Â  Â  Â  Idea for the template - if value is of 
    type1 then create Type <br><div class="im">object with &#39;Type1&#39; as name. If value is of 
    type2, use &#39;Type2&#39; as name: <br></div>  Â  Â  Â  <br>  
    Â  Â  Â  rule &quot;DC_@{row.rowNumber}&quot; <br>  Â  
    Â  Â  when <br>  Â  Â  Â  Â  Â  
    Service(name == &quot;DC&quot;) Â  Â  <br>  Â  Â  Â  
    then <br>  Â  Â  Â  Â  Â  
    Type.setName(eval(Service.getType(@{value}))) <br>  Â  Â  
    Â  Â  Â  Type.setAtt(0,@{value}) <br>  Â  Â  
    Â  end template <br>  Â  Â  Â  <br>  Â  
    Â  Â  eval(Service.getType(@{arg0})) should take &#39;AAA&#39; or &#39;XYZ&#39; 
    etc as <br><div class="im">arg and return a string Type1/Type2 etc. <br></div>  Â  
    Â  Â  <br>  Â  Â  Â  This would then generate 
    2 rules that look like: <br>  Â  Â  Â  <br>  
    Â  Â  Â  rule &quot;DC_0&quot; <br>  Â  Â  Â  when 
    <br>  Â  Â  Â  Â  Â  Service(name == &quot;DC&quot;, 
    value == &quot;AAA&quot;) Â  Â  <br>  Â  Â  Â  then 
    <br>  Â  Â  Â  Â  Â  
    RiskType.setName(&quot;Type1&quot;) <br>  Â  Â  Â  Â  
    Â  RiskType.setAtt(0,&quot;AAA&quot;) <br>  Â  Â  Â  
    <br>  Â  Â  Â  rule &quot;DC_1&quot; <br>  Â  Â  
    Â  when <br>  Â  Â  Â  Â  Â  
    Service(name == &quot;DC&quot;, value == &quot;XYZ&quot;) Â  Â  <br>  Â  
    Â  Â  then <br>  Â  Â  Â  Â  Â  
    RiskType.setName(&quot;Type2&quot;) <br>  Â  Â  Â  Â  
    Â  RiskType.setAtt(0,&quot;XYZ&quot;) <br>  Â  Â  Â  
    <br>  Â  Â  Â  ...is this possible at all? I&#39;m trying 
    to avoid the eval step <br><div class="im">being done in the actual rule (.drl) . 
    <br></div>  Â  Â  Â  <br>  Â  Â  Â  
    Thanks <br>  Â  Â  Â  <br>  Â  Â  
    Â  Chris <br><div class="im"><br><br><br>________________________________ <br><br>If 
    you reply to this email, your message will be added to the discussion 
    <br>below: <br><a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006589.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006589.html</a><br>
<br>To 
    unsubscribe from Smart Templates, click here <br>&lt;<a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubs" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubs</a><br>
cribe_by_code&amp;node=3006479&amp;code=Y2hyaXN0b3BoZXIubXVsbGFyZEBjcmVkaXQtc3Vp 
    <br>c3NlLmNvbXwzMDA2NDc5fDE5NzczMDY1MzE=&gt; . 
    <br><br>=============================================================================== 
    <br>Please access the attached hyperlink for an important electronic 
    communications disclaimer: <br></div><a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html" rel="nofollow" link="external" target="_blank">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a>  
    <br>=============================================================================== 
    </div></div></blockquote><div class="im"><br><br>
  <hr noshade size="1" color="#cccccc">

  <div style="font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; color: rgb(68, 68, 68); font-size-adjust: none; font-stretch: normal;">

  <div style="font-weight: bold;">If you reply to this email, your message will 
  be added to the discussion below:</div><a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006773.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006773.html</a> 
  </div>
  <div style="margin-top: 0.4em; font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; color: rgb(102, 102, 102); font-size-adjust: none; font-stretch: normal;">
To 
  unsubscribe from Smart Templates, <a rel="nofollow" link="external">click here</a>. </div><br>
  <p class="MsoNormal"><span style="font-size: 8pt; font-family: Courier;" lang="EN-US">==============================================================================<br>Please 
  access the attached hyperlink for an important electronic communications 
  disclaimer:<br><a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html" rel="nofollow" link="external" target="_blank">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a><br>==============================================================================</span></p>
<br><br>
  <hr width="300" align="left">
  View this message in context: <a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3009838.html" rel="nofollow" link="external" target="_blank">RE: Smart Templates</a><br>Sent 
  from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html" rel="nofollow" link="external" target="_blank">Drools: User forum mailing list 
  archive</a> at 
  Nabble.com.<br><br>_______________________________________________<br>rules-users 
  mailing list<br></div><a href="http://user/SendEmail.jtp?type=node&amp;node=3009984&amp;i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a><div class="im"><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></div></blockquote></div><br><br>_______________________________________________ 
<br>rules-users mailing list <br><a href="http://user/SendEmail.jtp?type=node&amp;node=3009984&amp;i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a> <br><div class="im"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br><br>
</div><hr noshade size="1" color="#cccccc">

<div style="font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(68, 68, 68);">
<div class="im">
<div style="font-weight: bold;">If you reply to this email, your message will be 
added to the discussion below:</div></div><a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3009984.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3009984.html</a> 
</div><div class="im">
<div style="margin-top: 0.4em; font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(102, 102, 102);">
To 
unsubscribe from Smart Templates, <a rel="nofollow" link="external">click 
here</a>. </div> <br><p class="MsoNormal"><span style="font-size: 8pt; font-family: Courier;" lang="EN-US">==============================================================================<br>Please access the attached hyperlink for an important electronic communications disclaimer:<br>
<a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html" rel="nofollow" link="external" target="_blank">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a><br>==============================================================================</span></p>
 <br>


        
<br><hr width="300" align="left"></div>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010031.html" target="_blank">RE: [rules-users] Smart Templates</a><div><div></div><div class="h5"><br>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html" target="_blank">Drools: User forum mailing list archive</a> at Nabble.com.<br></div></div><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></blockquote></div><br>