First, you don't need to compie the change set by your self the agent will do that in applyChangeSet() method.
Some questions that could help to figure out the problem:
  1. Which version of drools are you using? (I assume >= 5.1M1)
  2. Do you have any stacktrace/log file?
  3. Is your cange set pointing to DRL resources. If so, the agent internally  creates kbuilders to compile them. You could have class loaders problems there. By default the agent logs everything to System.err. Could you post the output here?

On Fri, Jun 25, 2010 at 9:59 AM, mmarmol <> wrote:

Hi, I have managed to install Drools-core and Drools-compiler in my Equinox
osgi environment, I can compile rules and execute them just fine, I was just
wandering how to configure a KnowledgeAgent using
KnowledgeBuilderFactoryService and KnowledgeBaseFactoryService. I managed to
configure one but i am not able to reload rules when they change at runtime.
I have started ResourceChangeScannerService and
ResourceChangeNotifierService, changeset related to the rules file gets read
but no change gets implemented. An idea?

Here is the code:


               ServiceReference serviceRef = bc
               ServiceRegistry registry = (ServiceRegistry) bc.getService(serviceRef);

               KnowledgeBuilderFactoryService knowledgeBuilderFactoryService = registry

               KnowledgeBaseFactoryService knowledgeBaseFactoryService = registry
               ResourceFactoryService resourceFactoryService = registry

               KnowledgeBuilderConfiguration kbConf = knowledgeBuilderFactoryService
                               .newKnowledgeBuilderConfiguration(null, getClass()

               KnowledgeBuilder kbuilder = knowledgeBuilderFactoryService
               ResourceFactoryService resource = resourceFactoryService;

               if (kbuilder.hasErrors()) {
                       throw new RuntimeException(kbuilder.getErrors().toString());

               KnowledgeBaseConfiguration kbaseConf = knowledgeBaseFactoryService
                               .newKnowledgeBaseConfiguration(null, getClass()

               KnowledgeBase kbase = knowledgeBaseFactoryService

               KnowledgeAgentConfiguration aconf =
               aconf.setProperty("drools.agent.scanDirectories", "true");
               aconf.setProperty("drools.agent.scanResources", "true");
               aconf.setProperty("drools.agent.newInstance", "false");

               kagent = KnowledgeAgentFactory.newKnowledgeAgent( "CoreDroolsAgent",kbase,

Thanks in advance!

View this message in context:
Sent from the Drools - User mailing list archive at
rules-users mailing list


Esteban Aliverti