It's not an obvious how to OSGI-fy something :)<div><br></div><div>I did some homework - now I have OSGi-ified versions of drools-spring and drools-camel.</div><div>Also I created own bundle and tried to import KnowledgeBaseFactoryService, ServiceRegistry and KnowledgeBaseFactoryService as described in <a href="http://docs.jboss.org/jbpm/v5.2/userguide/ch18.html#d0e4308">http://docs.jboss.org/jbpm/v5.2/userguide/ch18.html#d0e4308</a>.</div>
<div>All what I got - NullPointerException from karaf core (haven't gotten full staketrace yet. For some reason it is just:</div><div><div>15:11:34,484 | INFO | l Console Thread | Console | ? ? | 34 - org.apache.karaf.shell.console - 2.2.2.fuse-02-13 | Exception caught while executing command</div>
<div>java.lang.NullPointerException</div></div><div>)</div><div><br></div><div>So, I spent some time randomly adding and removing configuration params and I found - NPE occurs when I'm trying to import</div><div>org.drools.KnowledgeBaseFactoryService.</div>
<div>I guess (i'm not OSGI expert) it could be because org.drools package is exported in 2! bundles. It is in drools-core and knowledge-api bundles. And I guess, karaf container just can't link my bundle with both core and api, only first bundle which contains requested package (org.drools) wins.</div>
<div><br></div><div>Any ideas on how to make it work? </div><div>I actually have one - every bundle should export own package. For knowledge-api it should be org.drools.api, and org.drools.core for drools-core.</div><div>
<br></div><div>Here is full log of similar packages:</div><div><div>WARNING: multiple bundles are exporting package org.drools.command</div><div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><div>- org.drools.internalapi [217]</div>
<div><br></div><div>WARNING: multiple bundles are exporting package org.drools.runtime.process</div><div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><div><br></div><div>WARNING: multiple bundles are exporting package org.drools.time</div>
<div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><div><br></div><div>WARNING: multiple bundles are exporting package org.apache.geronimo.transaction</div><div>- org.apache.aries.transaction.manager [123]</div>
<div>- org.apache.aries.transaction.manager [51]</div><div><br></div><div>WARNING: multiple bundles are exporting package org.drools</div><div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><div><br></div><div>
WARNING: multiple bundles are exporting package org.apache.geronimo.transaction.manager</div><div>- org.apache.aries.transaction.manager [123]</div><div>- org.apache.aries.transaction.manager [51]</div><div><br></div><div>
WARNING: multiple bundles are exporting package org.drools.grid</div><div>- org.drools.core [218]</div><div>- org.drools.spring [220]</div><div><br></div><div>WARNING: multiple bundles are exporting package jline</div><div>
- org.apache.servicemix.bundles.jruby [210]</div><div>- org.apache.karaf.shell.console [34]</div><div><br></div><div>WARNING: multiple bundles are exporting package org.apache.geronimo.transaction.log</div><div>- org.apache.aries.transaction.manager [123]</div>
<div>- org.apache.aries.transaction.manager [51]</div><div><br></div><div>WARNING: multiple bundles are exporting package org.drools.management</div><div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><div>
<br></div><div>WARNING: multiple bundles are exporting package org.drools.agent</div><div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><div><br></div><div>WARNING: multiple bundles are exporting package org.drools.event</div>
<div>- org.drools.core [218]</div><div>- org.drools.api [216]</div><br><div class="gmail_quote">2012/2/3 Mark Proctor <span dir="ltr"><<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
neither spring or camel have been OSGi-ified. only api, core,
compiler, templates, decision-tables and flow have.<br>
<br>
If someone wants to OSGi-ify those and contribute back they are very
welcome:<br>
1) update the pom.xml to use the osgi bundle plugin, see other
existing poms.<br>
<a href="https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/pom.xml" target="_blank">https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/pom.xml</a><br>
2) create an Activator to register the module, again see Activator's
for core, compiler etc.<br>
<a href="https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/src/main/java/org/drools/osgi/decisiontables/Activator.java" target="_blank">https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/src/main/java/org/drools/osgi/decisiontables/Activator.java</a><br>
3) update the osgi bundle's pom with new dependencies, make sure to
pull in the spring ones, unless the actual project provides osgi
ready jars.<br>
<a href="https://github.com/droolsjbpm/droolsjbpm-build-distribution/tree/master/drools-osgi-bundles" target="_blank">https://github.com/droolsjbpm/droolsjbpm-build-distribution/tree/master/drools-osgi-bundles</a><br>
4) Update the boot-bundles.properties so that Spring DM loads the
OSGi dependencies<br>
<a href="https://github.com/droolsjbpm/droolsjbpm-build-distribution/blob/master/drools-osgi-bundles/org.drools.osgi.test/src/test/filtered-resources/boot-bundles.properties" target="_blank">https://github.com/droolsjbpm/droolsjbpm-build-distribution/blob/master/drools-osgi-bundles/org.drools.osgi.test/src/test/filtered-resources/boot-bundles.properties</a><br>
5) write unit tests for spring and camel.<br>
<br>
Mark<br>
On 03/02/2012 03:47, Alexander Filipchik wrote:
<blockquote type="cite">Hello all!
<div><br>
</div>
<div>Don't know if it is right list to ask, but I'm trying to make
drools + camel running on Fuse (ServiceMix container).</div>
<div>I couldn't even install OSGI drools artifacts for 5.3.1
version (because of weird dependency on drools.core Snapshot),</div>
<div>but did it with v5.2.1. I used:</div>
<p>mvel2/2.1.0,
org.drools/drools-core/5.2.1.Final, org.drools/drools-compiler/5.2.1.Final,
org.drools/<span>knowledge-api</span>/5.2.1.Final
and org.drools/drools-camel/5.2.1.Final.</p>
<p>
All are installed and active. Part of log:</p>
<p>[ 162] [Active ] [ ] [ ] [
60] Drools :: Compiler (5.2.1.Final)</p>
<p>[ 163] [Active ] [ ] [ ] [
60] mvel2 (2.1.0.drools4)</p>
<p>[ 164] [Active ] [ ] [ ] [
60] Drools :: Core (5.2.1.Final)</p>
<p>[ 165] [Active ] [ ] [ ] [
60] Knowledge API (5.2.1.Final)</p>
<p>[ 172] [Active ] [ ] [ ] [
60] mvn:org.drools/drools-camel/5.2.1.Final</p>
<p>Then I tried to add my own camel-drools router (I
created OSGI bundle for it). It depends on:</p>
<p>Import-Package:
org.apache.activemq,org.apache.activemq.camel.component,org.apache.activemq.pool,org.apache.camel;version="[2.8,3)",org.apache.camel.builder;version="[2.8,3)",org.apache.camel.component.jms;version="[2.8,3)",org.apache.camel.model;version="[2.8,3)",org.drools.camel.component,org.osgi.service.blueprint;version="[1.0.0,2.0.0)",org.springframework.transaction;version="[3,4)"</p>
<p>It tried to install it to a container but all I got
- </p>
<p>Error executing command: Unresolved constraint in
bundle com.betfair.drools [170]: Unable to resolve 170.0:
missing requirement [170.0] package;
(package=org.drools.camel.component)</p>
<div>I even tried to put drools-camel.jar
with org.drools.camel.component in a lib folder and add package
to org.osgi.framework.system.packages.extra, but got same
result.</div>
<div><br>
</div>
<div>Do you have any idea, blog posts, samples which could help
me?</div>
<div>I'm completely stuck.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Alex</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<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>
<br></blockquote></div><br></div>