This also works:
Map<String,String> a = new HashMap<>();
More ways to run into an error
Map<String,String> a;
a = new HashMap<String,String>();
etc.
Using 6.0.0-Final
-W
On 17/05/2014, rjh <raojinghai(a)gmail.com> wrote:
Hi,
I got a weird problem. A Java List/Map with generics can be used together
with modify() in the same rule. For example, a simple rule like the
following:
package com.sample
import java.util.Map;
import java.util.HashMap;
declare TestFact
@propertyReactive
data : String
end
rule "init"
when
not TestFact()
then
insert (new TestFact());
end
rule "Test Rule"
when
$fact : TestFact()
then
System.out.println( "Hello" );
Map<String,String> a = new HashMap<String,String>();
modify ($fact) {setData("0")}
end
I got the following error message:
java.lang.RuntimeException: Error while creating KieBase[Message [id=1,
level=ERROR, path=rules/Sample.drl, line=18, column=0
text=Unable to resolve type Map<String,String>:
Unable to find class 'Map<String,String>']]
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.getKieBase(KieContainerImpl.java:260)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:400)
at
org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:375)
at com.sample.DroolsTest.main(DroolsTest.java:17)
However, if I remove "<String,String>" from
"Map<String,String>", or remove
the "modify" line, the code is correct then.
Thank you!
Jinghai
--
View this message in context:
http://drools.46999.n3.nabble.com/Map-String-String-and-modify-can-t-be-t...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users