I have done the following: - Created a new Project in Eclipse, "Plug-in from existing jar archives" : added the .jar files of the lib directory in org.drools.eclipse-5.1.0.SNAPSHOT.zip.<https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/org.drools.eclipse-5.1.0.SNAPSHOT.zip> - Created a new project: droolstest, based on the example code in SimpleOsgiTest. - This is the code:
@SuppressWarnings("unchecked") public void testCompiler() throws Exception { ServiceReference serviceRef = bundleContext.getServiceReference( ServiceRegistry.class.getName() ); ServiceRegistry registry = (ServiceRegistry) bundleContext.getService( serviceRef ); * KnowledgeBuilderFactoryService knowledgeBuilderFactoryService = registry.get( KnowledgeBuilderFactoryService.class );* KnowledgeBaseFactoryService knowledgeBaseFactoryService = registry.get( KnowledgeBaseFactoryService.class ); ResourceFactoryService resourceFactoryService = registry.get( ResourceFactoryService.class ); String str = ""; str += "package org.test\n"; str += "import org.test.Person\n"; str += "global java.util.List list\n"; str += "rule rule1\n"; str += "when\n"; str += " $p : Person( age > 30 )\n"; str += "then\n"; str += " list.add($p);\n"; str += "end\n"; KnowledgeBuilderConfiguration kbConf = knowledgeBuilderFactoryService.newKnowledgeBuilderConfiguration( null, getClass().getClassLoader() ); KnowledgeBuilder kbuilder = knowledgeBuilderFactoryService.newKnowledgeBuilder( kbConf ); ResourceFactoryService resource = resourceFactoryService; kbuilder.add( resource.newByteArrayResource( str.getBytes() ), ResourceType.DRL ); if ( kbuilder.hasErrors() ) { System.out.println( kbuilder.getErrors() ); throw new RuntimeException( kbuilder.getErrors().toString() ); } KnowledgeBaseConfiguration kbaseConf = knowledgeBaseFactoryService.newKnowledgeBaseConfiguration( null, getClass().getClassLoader() ); KnowledgeBase kbase = knowledgeBaseFactoryService.newKnowledgeBase( kbaseConf ); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); List list = new ArrayList(); ksession.setGlobal( "list", list ); ksession.insert( new Person( "name", 34 ) ); ksession.fireAllRules(); ksession.dispose(); } public class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } } The other methods work fine. I then added the following packages to my dependencies in the manifest: Import-Package: org.drools, org.drools.builder, org.drools.builder.impl, org.drools.io, org.drools.rule, org.drools.rule.builder, org.drools.runtime, org.drools.runtime.rule, org.drools.util, org.drools.vsm;version="5.1.0.SNAPSHOT", org.osgi.framework;version="1.5.0" However, when I run I get this error: Testing compiler org.osgi.framework.BundleException: Activator start error in bundle droolstest [2]. at org.apache.felix.framework.Felix.activateBundle(Felix.java:1751) at org.apache.felix.framework.Felix.startBundle(Felix.java:1622) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915) at org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:114) at org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:286) at org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:184) at java.lang.Thread.run(Unknown Source) *Caused by: java.lang.IllegalArgumentException: Unable to instantiate service for Class 'org.drools.builder.KnowledgeBuilderFactoryService'* at org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:157) * at droolstest.Activator$SimpleOsgiTest.testCompiler(Activator.java:79)* at droolstest.Activator.start(Activator.java:44) at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:639) at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700) ... 6 more Caused by: java.lang.ClassCastException at java.lang.Class.cast(Unknown Source) at org.drools.util.ServiceRegistryImpl.get(ServiceRegistryImpl.java:155) ... 10 more java.lang.IllegalArgumentException: Unable to instantiate service for Class 'org.drools.builder.KnowledgeBuilderFactoryService' -> The registry is not null. He just can't seem to find this service. Allthough the drools project with all bundles of the lib directory in org.drools.eclipse-5.1.0.SNAPSHOT.zip.<https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/org.drools.eclipse-5.1.0.SNAPSHOT.zip>are installed and started. (this should register the service I believe) These issues have been driving me crazy. :-( Kind regards Aerv
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users