<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">Hi Joseph,</span><div><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">1.  I need to rebuild the rules on the fly, so I was using examples from</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">the IncrementalCompilationTest.</span><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">java</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">&lt;</span><a href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java" target="_blank" style="font-family:arial,sans-serif;font-size:12.727272033691406px">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java</a><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">&gt;</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">to accomplish that task.  However, those tests don&#39;t use a classpath</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">container... can I still rebuild a KieModule via runtime code when running</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">in a classpathContainer?</span></div><div><br></div><div>&gt;&gt; <span style="font-family:arial,sans-serif;font-size:12.727272033691406px">My example uses this META-INF/kmodules.xml file to let the KieContainer to scan and discover the resources (.drl, pacjkages) when we call </span></div>
<div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><div class="" id="LC22" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;padding-left:10px">
<span class="" style>   KieContainer</span> <span class="" style>kcont</span> <span class="" style="font-weight:bold">=</span> <span class="" style>ks</span><span class="" style="font-weight:bold">.</span><span class="" style="color:teal">newKieClasspathContainer</span><span class="" style="font-weight:bold">(</span><span class="" style>getClass</span><span class="" style="font-weight:bold">().</span><span class="" style="color:teal">getClassLoader</span><span class="" style="font-weight:bold">());</span></div>
<div class="" id="LC23" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;padding-left:10px">   <span class="" style>KieBase</span> <span class="" style>kbase</span> <span class="" style="font-weight:bold">=</span> <span class="" style>kcont</span><span class="" style="font-weight:bold">.</span><span class="" style="color:teal">getKieBase</span><span class="" style="font-weight:bold">(</span><span class="" style="color:rgb(221,17,68)">&quot;sampleKBase&quot;</span><span class="" style="font-weight:bold">);</span></div>
<div class="" id="LC23" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;padding-left:10px"><span style="font-weight:bold;font-size:12px"><br></span></div>
<div class="" id="LC23" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;padding-left:10px"><span style="font-weight:bold;font-size:12px">As you have mentioned in your email, this is a static approach as we load the resources before to create a KieSession and fire the rules.</span><br>
</div><div class="" id="LC23" style="padding-left:10px"><span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;font-weight:bold">To be able to do increment, the approach that you mention is the way to go. I have also created an example where the KieModule is created using a programming approach --&gt; </span><font color="#333333" face="Consolas, Liberation Mono, Courier, monospace"><span style="line-height:18px"><b><a href="https://github.com/cmoulliard/droolsjbpm-osgi-examples/blob/master/simple-external-resource/src/main/java/org/drools/example/osgi/FetchExternalResourceOsgiActivator.java">https://github.com/cmoulliard/droolsjbpm-osgi-examples/blob/master/simple-external-resource/src/main/java/org/drools/example/osgi/FetchExternalResourceOsgiActivator.java</a>. That should not be difficult to adapt it to support increment</b></span></font><span style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;font-weight:bold"> </span></div>
<div class="" id="LC23" style="color:rgb(51,51,51);font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:12px;line-height:18px;padding-left:10px"><span class="" style="font-weight:bold"><br></span></div>
</pre><br style="font-family:arial,sans-serif;font-size:12.727272033691406px"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">2.  Your example code calls .newKieSession() on a kbase object as opposed to</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">a kContainer object.  Is there a reason why?  If I create a new KieSession</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">from a kbase vs. kContainer, will I still be able to rebuild the kjar</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">dynamically in the code and keep using the same stateful session?</span></div><div><br></div><div>I need that Mario Fusco or Marc Proctor confirm what I will say here (or somebody) else but I suspect that if you create a session on the KieContainer level and not on the KieBase could allow you to support increment as this unit test show you (<a href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java#L660">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java#L660</a>) without having to recreate a new session (stateless) <br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<br style="font-family:arial,sans-serif;font-size:12.727272033691406px"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">3.  It looks like I&#39;ll have to wait until Drools 6.1.0 to get the parameter</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">to specify a classloader when creating the container?  I see you just added</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">that recently.  I&#39;ve tried using</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">Thread.currentThread().</span><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">setContextClassLoader(...) but can&#39;t seem to make</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">that work with Drools 6.0.1 in Karaf 2.3.3 because then</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">RuleBaseConfiguration sets the classloader and uses it to try resolving</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">org.drools.core.conflict.</span><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">DepthConflictResolver, which it can&#39;t do because</span><br style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<span style="font-family:arial,sans-serif;font-size:12.727272033691406px">it&#39;s no longer using the OSGi classloader.</span></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">&gt;&gt; I have no ideas if my modifications will be merged with 6.0.x release. Mario Fusco should be able to provide a response<br>
</font><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">Regards,</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
 </div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 23, 2014 at 6:01 PM, jhusby <span dir="ltr">&lt;<a href="mailto:husby024@umn.edu" target="_blank">husby024@umn.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I actually looked through your example project yesterday; very helpful!!!<br>
However, there are a few things I&#39;m not sure are compatible with what I&#39;m<br>
trying to do.<br>
<br>
1.  I need to rebuild the rules on the fly, so I was using examples from<br>
the IncrementalCompilationTest.java<br>
&lt;<a href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java" target="_blank">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java</a>&gt;<br>

to accomplish that task.  However, those tests don&#39;t use a classpath<br>
container... can I still rebuild a KieModule via runtime code when running<br>
in a classpathContainer?<br>
<br>
2.  Your example code calls .newKieSession() on a kbase object as opposed to<br>
a kContainer object.  Is there a reason why?  If I create a new KieSession<br>
from a kbase vs. kContainer, will I still be able to rebuild the kjar<br>
dynamically in the code and keep using the same stateful session?<br>
<br>
3.  It looks like I&#39;ll have to wait until Drools 6.1.0 to get the parameter<br>
to specify a classloader when creating the container?  I see you just added<br>
that recently.  I&#39;ve tried using<br>
Thread.currentThread().setContextClassLoader(...) but can&#39;t seem to make<br>
that work with Drools 6.0.1 in Karaf 2.3.3 because then<br>
RuleBaseConfiguration sets the classloader and uses it to try resolving<br>
org.drools.core.conflict.DepthConflictResolver, which it can&#39;t do because<br>
it&#39;s no longer using the OSGi classloader.<br>
<br>
Thank you,<br>
<br>
Joseph<br>
<br>
<br>
Charles Moulliard-2 wrote<br>
<div class="im">&gt; Hi Joseph,<br>
&gt;<br>
&gt; I propose that you have a look to this example which is currently working<br>
&gt; on Karaf - <a href="https://github.com/cmoulliard/droolsjbpm-osgi-examples" target="_blank">https://github.com/cmoulliard/droolsjbpm-osgi-examples</a> (simple<br>
&gt; =<br>
&gt; OSGI BundleActivator + KieSession + Drools Rules)<br>
&gt;<br>
&gt; Regards,<br>
&gt;<br>
&gt; Charles<br>
<br>
<br>
<br>
<br>
<br>
</div>--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/kContainer-newKieSession-fails-in-Apache-Karaf-tp4027815p4027838.html" target="_blank">http://drools.46999.n3.nabble.com/kContainer-newKieSession-fails-in-Apache-Karaf-tp4027815p4027838.html</a><br>

<div class="HOEnZb"><div class="h5">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>
</div></div></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>