[rules-users] Drools and OSGi

AervTerrh woutervanisterdael at gmail.com
Fri Apr 2 18:42:04 EDT 2010


Hey,

Okay. I know this problem can be found all over. But I can't seem to figure
out a solution to it. Somehow I must be doing something wrong. I've created
a simple application that evaluates some rules and changes some objects
based on that. Everything worked fine, not a single problem there. All
libraries could be easily found etc.

Now I wanted to convert this to a Felix OSGi bundle.

So, what I did, was creating a bundle (new plugin project based on existing
jars) with the drools jars (core, compiler, api, jsr) and tried the next
code in the RuleEngine class:

Properties props = new Properties();
props.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(props, null);
(here's where it fails)
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
kbuilder.add(ResourceFactory.newClassPathResource(fileName,
RuleEngine.class), ResourceType.DRL);

This is pretty much the loading of the rule file. The RuleEngine is started
in an Activator. The file is found and everything. But I keep getting the
same error when starting the bundle.

org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.mvel.MVELDialectConfigurati on:mvel:null'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(P
ackageBuilderConfiguration.java:274)
at org.drools.compiler.PackageBuilderConfiguration.buildDialect
ConfigurationMap(PackageBuilderConfiguration.java:259)
at org.drools.compiler.PackageBuilderConfiguration.init(Package
BuilderConfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:148)
at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnow
ledgeBuilderConfiguration(KnowledgeBuilderProviderImpl.java: 21)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuild
erConfiguration(KnowledgeBuilderFactory.java:68)
at test.Activator$RuleCreator.createRule(Activator.java:52)
at test.Activator.start(Activator.java:32)
at org.apache.felix.framework.util.SecureAction.startActivator(
SecureAction.java:639)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1 700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622 )
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.j ava:1077)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl .java:264)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.mvel.MVELDialectConfiguratio n
at java.net.URLClassLoader$1.run(Unknown Source)


The packages I import in the manifest:
Import-Package: org.codehaus.janino;version="2.4.3",
org.drools,
org.drools.builder,
org.drools.compiler,
org.drools.io,
org.drools.rule,
org.drools.rule.builder.dialect.java,
org.drools.rule.builder.dialect.mvel,
org.osgi.framework;version="1.3.0"

In my target platform I add the the drools project I created (with
drools-xx.jar (the necessary ones), I also added the following:
-ant
-antlr-runtime
-janino
-jsr94
-xstream

But I can't seem to get it working... Does anyone know what can be done
about this? Or a working example of Drools in Felix OSGi would also be
helpful.

Any help is very much appreciated, I've been looking into this for days.

Thanks!

Kind regards,

Aerv
-- 
View this message in context: http://n3.nabble.com/Drools-and-OSGi-tp694011p694011.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list