<div dir="ltr">Is it a list that you would like to use as global param ? If this is the case, maybe change your rule & code like that <div><br></div><div><div> //GET A KSESSION</div><div> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</div>
<div><br></div><div> //now create some test data</div><div> ksession.insert( new Cheese( "stilton",</div><div> 42 ) );</div><div> ksession.insert( new Person( "michael",</div>
<div> "stilton",</div><div> 42 ) );</div><div> final List<String> list = new ArrayList<String>();</div><div> ksession.setGlobal( "list",</div>
<div> list );</div><div><br></div><div> ksession.fireAllRules();</div><div><br></div><div> System.out.println(list);</div><div><br></div><div> ksession.dispose();</div><div><br></div>
<div>Rule </div><div><br></div><div><div>template header</div><div>age</div><div>type</div><div>log</div><div><br></div><div>package org.drools.examples.templates;</div><div><br></div><div>global java.util.List list;</div>
<div><br></div><div>template "cheesefans"</div><div><br></div><div>rule "Cheese fans_@{row.rowNumber}"</div><div> when</div><div> Person(age == @{age})</div><div> Cheese(type == "@{type}")</div>
<div> then</div><div> list.add("@{log}");</div><div>end</div><div>end template</div></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 20, 2014 at 4:40 PM, Ephemeris Lappis <span dir="ltr"><<a href="mailto:ephemeris.lappis@gmail.com" target="_blank">ephemeris.lappis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hello.</div><div><br></div><div>I have no such kind test with Pax Exam. Should you send me a simple maven project example using a Karaf container ?</div>
<div><br></div><div>Back to the problem, a very simple rule with something like that in the RHS always fails when deployed in a bundle whose class loader is the felix one :</div>
<div><br></div><div>List<String> l = new ArrayList<>();</div><div>that must be fixed with :</div><div>List<String> l = new ArrayList<String>();</div><div><br></div><div>or</div><div><br></div><div>
int n = 1_000;</div><div>that fails instead of :</div><div>int n = 1000;</div><div><br></div><div>FYI, I use ServiceMix 4.5.3.</div><div><br></div><div>Thanks again.</div><div>Regards.</div></div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-05-20 15:41 GMT+02:00 Charles Moulliard <span dir="ltr"><<a href="mailto:ch007m@gmail.com" target="_blank">ch007m@gmail.com</a>></span>:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">A test case will be required to reproduce your problem. Do you have a pax-exam test ?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 20, 2014 at 1:03 PM, Ephemeris Lappis <span dir="ltr"><<a href="mailto:ephemeris.lappis@gmail.com" target="_blank">ephemeris.lappis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br>
<br>
Here is the first lines of the error message :<br>
<br>
<br>
14:58:57,457 | ERROR | tp1946301910-151 | AbstractKieModule |<br>
239 - org.drools.compiler - 6.1.0.20140429-1643 | Unable to build<br>
KieBaseModel:MyKBase<br>
Rule Compilation error : [Rule name='Main Rule']<br>
my/tests/drools/osgi/expert/rules/Rule_Main_Rule1409557233.java (8:649) :<br>
Incorrect number of arguments for type HashMap<K,V>; it cannot be<br>
parameterized with arguments <?><br>
my/tests/drools/osgi/expert/rules/Rule_Main_Rule1409557233.java (8:666) :<br>
Syntax error on token "<", ? expected after this token<br>
<br>
<br>
I have found the explanation and a workaround : put it all with a strict<br>
"1.5" syntax in the RHS ! In this current case, do not use <> to infere the<br>
generic type, but use the expected declared types instead.<br>
<br>
After a rather touchy remote debug of the ServiceMix runtime to inspect what<br>
is different from the Junit tests, I think that the problem comes from the<br>
classloader that is associated with the Kie container. Before compilation<br>
the language source and target level is set with version 1.7 as expected,<br>
but in the nameEnvironment that is passed to the JavaCompiler (indeed, ecj<br>
compiler), the droolsClassloader is of type<br>
"org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5". As its name<br>
seems to incidate, I'm afraid that the Karaf/Felix loader is originally<br>
built in 1.5.<br>
<br>
I've read some posts about the eclipse compiler that perhaps takes into<br>
account the caller compliance to adapt its compilation language level.<br>
<br>
Class loaders seem to be a serious problem when using Drools in complex<br>
environment such as a OSGi one...<br>
<br>
Please, could you confirm my analysis, and, if you have one, propose any<br>
better solution ? I don't know, for example, if it's possible to influence<br>
Karaf to use different levels of bundle class loaders...<br>
<br>
Thanks a lot.<br>
<br>
Regards.<br>
<br>
<br><span><font color="#888888">
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029622.html" target="_blank">http://drools.46999.n3.nabble.com/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029622.html</a><br>
<div><div>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" target="_blank">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></font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Charles Moulliard</div><div>Apache Committer / Architect @RedHat</div>
<div>Twitter : @cmoulliard | Blog : <a href="http://cmoulliard.github.io" target="_blank"> http://cmoulliard.github.io</a></div>
<div><br></div></div>
</font></span></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div></div></div><br></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></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>
Charles Moulliard</div><div>Apache Committer / Architect @RedHat</div><div>Twitter : @cmoulliard | Blog : <a href="http://cmoulliard.github.io" target="_blank"> http://cmoulliard.github.io</a></div><div><br></div></div>
</div>