Hi Joseph,1. I need to rebuild the rules on the fly, so I was using examples from
the IncrementalCompilationTest.java
<https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java>
to accomplish that task. However, those tests don't use a classpath
container... can I still rebuild a KieModule via runtime code when running
in a classpathContainer?>> My example uses this META-INF/kmodules.xml file to let the KieContainer to scan and discover the resources (.drl, pacjkages) when we callKieContainer kcont = ks.newKieClasspathContainer(getClass().getClassLoader());KieBase kbase = kcont.getKieBase("sampleKBase");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.
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 --> https://github.com/cmoulliard/droolsjbpm-osgi-examples/blob/master/simple-external-resource/src/main/java/org/drools/example/osgi/FetchExternalResourceOsgiActivator.java. That should not be difficult to adapt it to support increment
2. Your example code calls .newKieSession() on a kbase object as opposed to
a kContainer object. Is there a reason why? If I create a new KieSession
from a kbase vs. kContainer, will I still be able to rebuild the kjar
dynamically in the code and keep using the same stateful session?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 (https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java#L660) without having to recreate a new session (stateless)
3. It looks like I'll have to wait until Drools 6.1.0 to get the parameter
to specify a classloader when creating the container? I see you just added
that recently. I've tried using
Thread.currentThread().setContextClassLoader(...) but can't seem to make
that work with Drools 6.0.1 in Karaf 2.3.3 because then
RuleBaseConfiguration sets the classloader and uses it to try resolving
org.drools.core.conflict.DepthConflictResolver, which it can't do because
it's no longer using the OSGi classloader.>> I have no ideas if my modifications will be merged with 6.0.x release. Mario Fusco should be able to provide a response
Regards,On Thu, Jan 23, 2014 at 6:01 PM, jhusby <husby024@umn.edu> wrote:
I actually looked through your example project yesterday; very helpful!!!
However, there are a few things I'm not sure are compatible with what I'm
trying to do.
1. I need to rebuild the rules on the fly, so I was using examples from
the IncrementalCompilationTest.java
<https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/IncrementalCompilationTest.java>
to accomplish that task. However, those tests don't use a classpath
container... can I still rebuild a KieModule via runtime code when running
in a classpathContainer?
2. Your example code calls .newKieSession() on a kbase object as opposed to
a kContainer object. Is there a reason why? If I create a new KieSession
from a kbase vs. kContainer, will I still be able to rebuild the kjar
dynamically in the code and keep using the same stateful session?
3. It looks like I'll have to wait until Drools 6.1.0 to get the parameter
to specify a classloader when creating the container? I see you just added
that recently. I've tried using
Thread.currentThread().setContextClassLoader(...) but can't seem to make
that work with Drools 6.0.1 in Karaf 2.3.3 because then
RuleBaseConfiguration sets the classloader and uses it to try resolving
org.drools.core.conflict.DepthConflictResolver, which it can't do because
it's no longer using the OSGi classloader.
Thank you,
Joseph
Charles Moulliard-2 wrote
> Hi Joseph,--
>
> I propose that you have a look to this example which is currently working
> on Karaf - https://github.com/cmoulliard/droolsjbpm-osgi-examples (simple
> =
> OSGI BundleActivator + KieSession + Drools Rules)
>
> Regards,
>
> Charles
View this message in context: http://drools.46999.n3.nabble.com/kContainer-newKieSession-fails-in-Apache-Karaf-tp4027815p4027838.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--Charles MoulliardApache Committer / Architect @RedHatTwitter : @cmoulliard | Blog : http://cmoulliard.github.io