<div dir="ltr">Hi Wolfgang,<div><br></div><div>You are right. It only happens for variable declaration. It has no problem on the right side. For example</div><div><br></div><div>Map a = new HashMap<String,String>()</div>
<div><br></div><div>has no problem. </div><div><br></div><div>I am using 6.0.1-Final.</div><div><br></div><div>Thanks.</div><div><br></div><div>Jinghai</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, May 16, 2014 at 11:58 PM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This also works:<br>
Map<String,String> a = new HashMap<>();<br>
<br>
More ways to run into an error<br>
Map<String,String> a;<br>
<div class=""> a = new HashMap<String,String>();<br>
</div>etc.<br>
<br>
Using 6.0.0-Final<br>
<span class="HOEnZb"><font color="#888888">-W<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 17/05/2014, rjh <<a href="mailto:raojinghai@gmail.com">raojinghai@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I got a weird problem. A Java List/Map with generics can be used together<br>
> with modify() in the same rule. For example, a simple rule like the<br>
> following:<br>
><br>
> package com.sample<br>
><br>
> import java.util.Map;<br>
> import java.util.HashMap;<br>
><br>
> declare TestFact<br>
> @propertyReactive<br>
> data : String<br>
> end<br>
><br>
> rule "init"<br>
> when<br>
> not TestFact()<br>
> then<br>
> insert (new TestFact());<br>
> end<br>
><br>
> rule "Test Rule"<br>
> when<br>
> $fact : TestFact()<br>
> then<br>
> System.out.println( "Hello" );<br>
> Map<String,String> a = new HashMap<String,String>();<br>
> modify ($fact) {setData("0")}<br>
> end<br>
><br>
> I got the following error message:<br>
><br>
> java.lang.RuntimeException: Error while creating KieBase[Message [id=1,<br>
> level=ERROR, path=rules/Sample.drl, line=18, column=0<br>
> text=Unable to resolve type Map<String,String>:<br>
> Unable to find class 'Map<String,String>']]<br>
> at<br>
> org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:260)<br>
> at<br>
> org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:400)<br>
> at<br>
> org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:375)<br>
> at com.sample.DroolsTest.main(DroolsTest.java:17)<br>
><br>
> However, if I remove "<String,String>" from "Map<String,String>", or remove<br>
> the "modify" line, the code is correct then.<br>
><br>
> Thank you!<br>
><br>
> Jinghai<br>
><br>
><br>
><br>
><br>
> --<br>
> View this message in context:<br>
> <a href="http://drools.46999.n3.nabble.com/Map-String-String-and-modify-can-t-be-together-tp4029591.html" target="_blank">http://drools.46999.n3.nabble.com/Map-String-String-and-modify-can-t-be-together-tp4029591.html</a><br>
> Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
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></div>