<div dir="ltr">In this case it&#39;s not a global, but a temporary variable in the rule consequence. Indeed, the problem is not only about generics, but impacts all the syntax elements that may have changed since Java 1.5, and make the rules Java compiler fails when running in ServiceMix.<div>
<br></div><div>As I said before, the workaround is quite easy, changing all the Java code to be compliant with the compilation level. The question is just about a confirmation of the Felix&#39;s class loader (<span style="font-size:13px;font-family:arial,sans-serif">org/apache/felix/framework/</span><span style="font-size:13px;font-family:arial,sans-serif">ModuleImpl$</span><span style="font-size:13px;font-family:arial,sans-serif">ModuleClassLoaderJava5)</span> in the compiler&#39;s behavior, and a better solution to be able to write RHS with a &#39;modern&#39; syntax.</div>
<div><br></div><div>Thanks.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-20 16:56 GMT+02:00 Charles Moulliard [via Drools] <span dir="ltr">&lt;<a href="/user/SendEmail.jtp?type=node&node=4029629&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>&gt;</span>:<br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

        <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 &amp; 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( &quot;stilton&quot;,</div><div>                               42 ) );</div><div>        ksession.insert( new Person( &quot;michael&quot;,</div>

<div>                               &quot;stilton&quot;,</div><div>                               42 ) );</div><div>        final List&lt;String&gt; list = new ArrayList&lt;String&gt;();</div><div>        ksession.setGlobal( &quot;list&quot;,</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 &quot;cheesefans&quot;</div><div><br></div><div>rule &quot;Cheese fans_@{row.rowNumber}&quot;</div><div>    when</div><div>        Person(age == @{age})</div><div>        Cheese(type == &quot;@{type}&quot;)</div>

<div>    then</div><div>        list.add(&quot;@{log}&quot;);</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">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span> wrote:<br>

<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote"><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&lt;String&gt; l = new ArrayList&lt;&gt;();</div><div>that must be fixed with :</div><div>List&lt;String&gt; l = new ArrayList&lt;String&gt;();</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">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span>:<div>
<div><br><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote">

<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">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span> wrote:<br>



<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote">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=&#39;Main Rule&#39;]<br>
        my/tests/drools/osgi/expert/rules/Rule_Main_Rule1409557233.java (8:649) :<br>
Incorrect number of arguments for type HashMap&lt;K,V&gt;; it cannot be<br>
parameterized with arguments &lt;?&gt;<br>
        my/tests/drools/osgi/expert/rules/Rule_Main_Rule1409557233.java (8:666) :<br>
Syntax error on token &quot;&lt;&quot;, ? expected after this token<br>
<br>
<br>
I have found the explanation and a workaround : put it all with a strict<br>
&quot;1.5&quot; syntax in the RHS ! In this current case, do not use &lt;&gt; 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>
&quot;org/apache/felix/framework/ModuleImpl$ModuleClassLoaderJava5&quot;. As its name<br>
seems to incidate, I&#39;m afraid that the Karaf/Felix loader is originally<br>
built in 1.5.<br>
<br>
I&#39;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&#39;t know, for example, if it&#39;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" rel="nofollow" link="external" 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="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=3" rel="nofollow" link="external" target="_blank">[hidden email]</a><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>
</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" rel="nofollow" link="external" target="_blank"> http://cmoulliard.github.io</a></div>
<div><br></div></div>
</font></span></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=4" rel="nofollow" link="external" target="_blank">[hidden email]</a><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></blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=5" rel="nofollow" link="external" target="_blank">[hidden email]</a><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></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" rel="nofollow" link="external" target="_blank"> http://cmoulliard.github.io</a></div>
<div><br></div></div>
</div>
<br>_______________________________________________
<br>rules-users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&amp;node=4029628&amp;i=6" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<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>
        <hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <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/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029628.html" target="_blank" rel="nofollow" link="external">http://drools.46999.n3.nabble.com/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029628.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from Rules compilation error with OSGi integration (6.1.0.Beta3), <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>

                <a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&amp;id=instant_html%21nabble%3Aemail.naml&amp;base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&amp;breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
        </div></blockquote></div><br></div>


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://drools.46999.n3.nabble.com/Rules-compilation-error-with-OSGi-integration-6-1-0-Beta3-tp4029601p4029629.html">Re: [rules-users] Rules compilation error with OSGi integration (6.1.0.Beta3)</a><br/>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools: User forum mailing list archive</a> at Nabble.com.<br/>