Thank you both very much. I will try both suggestions, and will get back to you as soon as I've got it figured out :-)
Kind regards, Aerv 2010/4/15 Robert <[email protected]> > Hi Aerv, > > soon I will also have to launch Drools within an OSGI environment, but I > am not there yet. But within another context (jBPM) I had some troubles > looking similar you are having. > > It had something to do with the classloading. jBPM did not provide any > OSGI-support, whereas Droos does, so I am not sure if this fits, but I had > to wrap here and there some classes so they got pulled in by the right > ClassLoader (OSGI uses many class-loaders). > > > final ClassLoader origCl = > Thread.currentThread().getContextClassLoader(); > final ClassLoader cl = > <YOUR_CLASS_YOU_WANT_TO_USE>.class.getClassLoader(); > Thread.currentThread().setContextClassLoader(cl); > > ... use the class ... > > > Thread.currentThread().setContextClassLoader(origCl); > > Maybe this helps, > > Cheers, Rob. > > > Am 14.04.2010, 20:27 Uhr, schrieb Wouter Van Isterdael > <[email protected]>: > > > I still seem to be having problems getting it working. The problem did > > not > > go away. > > > > I still get the same error. Would anyone know of a simple step-by-step > > tutorial for using Drools in a Felix OSGi environment? Preferrably within > > Eclipse and with Pax Runner. > > > > Any help would be very much appreciated. > > > > Thank you for your time! > > > > Kind regards > > > > Aerv > > > > 2010/4/6 AervTerrh <[email protected]> > > > >> Thanks for the reply. I will try this tomorrow and keep you posted! > >> > >> 2010/4/5 Jason Davidson [via Drools - Java Rules Engine] <[hidden > >> email]< > http://n3.nabble.com/user/SendEmail.jtp?type=node&node=698969&i=0> > >> > > >> > >>> I don't know if this helps, but I had to turn the MVEL JIT compiler > >>> off in > >>> the Equinox OSGi container: > >>> OptimizerFactory.setDefaultOptimizer("reflective"); > >>> > >>> Also, we used pre-compiled packages instead of compiling the DRL files > >>> at > >>> runtime. For example: > >>> > >>> .... > >>> RuleBaseConfiguration ruleBaseConfig = new > >>> RuleBaseConfiguration(); > >>> > >>> ruleBaseConfig.setClassLoader(this.getClass().getClassLoader()); > >>> > >>> //MVEL in OSGi is a complete CF - this turns off the MVEL > >>> JIT > >>> - potential resource hog but that's the nature of OSGi classloading > >>> //and Drools... > >>> OptimizerFactory.setDefaultOptimizer("reflective"); > >>> > >>> RuleBase ruleBase = > >>> RuleBaseFactory.newRuleBase(ruleBaseConfig); > >>> > >>> InputStream pkgIs = > >>> > this.getClass().getResourceAsStream("/com/cjs/hazel/rules/com.cjs.hazel.rules.pkg"); > >>> addPackage(ruleBase,pkgIs); > >>> ..... > >>> > >>> On Fri, Apr 2, 2010 at 4:42 PM, AervTerrh <[hidden > >>> email]< > http://n3.nabble.com/user/SendEmail.jtp?type=node&node=698731&i=0> > >>> > wrote: > >>> > >>>> > >>>> 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. > >>>> _______________________________________________ > >>>> rules-users mailing list > >>>> [hidden > >>>> email]< > http://n3.nabble.com/user/SendEmail.jtp?type=node&node=698731&i=1> > >>>> > >>>> https://lists.jboss.org/mailman/listinfo/rules-users > >>>> > >>> > >>> > >>> _______________________________________________ > >>> rules-users mailing list > >>> [hidden > >>> email]< > http://n3.nabble.com/user/SendEmail.jtp?type=node&node=698731&i=2> > >>> https://lists.jboss.org/mailman/listinfo/rules-users > >>> > >> > >> > >> > >> -- > >> __________________________________ > >> Van Isterdael Wouter > >> Roesbeke 27 > >> 9402 Meerbeke > >> 0496401476 > >> > >> ------------------------------ > >> View this message in context: Re: Drools and > >> OSGi<http://n3.nabble.com/Drools-and-OSGi-tp694011p698969.html> > >> > >> Sent from the Drools - User mailing list > >> archive<http://n3.nabble.com/Drools-User-f47000.html>at Nabble.com. > >> > >> _______________________________________________ > >> rules-users mailing list > >> [email protected] > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > >> > > > > > > > -- > Erstellt mit Operas revolutionärem E-Mail-Modul: > http://www.opera.com/mail/ > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > -- __________________________________ Van Isterdael Wouter Roesbeke 27 9402 Meerbeke 0496401476
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
