2 Replies Latest reply on Mar 11, 2012 10:46 PM by TC ONG

    Unknown resource type: null when call kagent.applyChangeSet( resource ) the second time.

    TC ONG Newbie

                URL url = new URL(CHANGE_SET_URL);           UrlResource resource = (UrlResource) ResourceFactory.newUrlResource( url );                           KnowledgeAgentConfiguration agentConfig = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();              agentConfig.setProperty("drools.agent.newInstance", "true");              agentConfig.setProperty("drools.agent.scanDirectories", "false");                KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyKnowledgeAgent", agentConfig );                                KnowledgeAgentEventListener kaListener = new KnowledgeAgentEventListener() {                                          @Override                     public void resourceCompilationFailed(ResourceCompilationFailedEvent arg0) {                          logger.debug("resourceCompilationFailed");                     }                                          @Override                     public void knowledgeBaseUpdated(KnowledgeBaseUpdatedEvent arg0) {                          logger.debug("knowledgeBaseUpdated");                     }                                          @Override                     public void beforeResourceProcessed(BeforeResourceProcessedEvent arg0) {                          logger.debug("beforeResourceProcessed");                     }                                          @Override                     public void beforeChangeSetProcessed(BeforeChangeSetProcessedEvent arg0) {                          logger.debug("beforeChangeSetProcessed");                     }                                          @Override                     public void beforeChangeSetApplied(BeforeChangeSetAppliedEvent arg0) {                          logger.debug("beforeChangeSetApplied");                     }                                          @Override                     public void afterResourceProcessed(AfterResourceProcessedEvent arg0) {                          logger.debug("afterResourceProcessed");                     }                                          @Override                     public void afterChangeSetProcessed(AfterChangeSetProcessedEvent arg0) {                          logger.debug("afterChangeSetProcessed");                     }                                          @Override                     public void afterChangeSetApplied(AfterChangeSetAppliedEvent arg0) {                          logger.debug("afterChangeSetApplied");                     }                };                                kagent.addEventListener(kaListener);                                kagent.applyChangeSet( resource );                                kagent.monitorResourceChangeEvents(true);

       

      The code above is ok but when I call

       

      kagent.applyChangeSet( resource );

       

      again then I get

      Exception in thread "Thread-3" java.lang.RuntimeException: Unknown resource type: null
           at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:686)
           at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
           at org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:712)
           at org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1002)
           at org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:785)
           at org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:657)
           at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:190)
           at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:169)
           at com.geneoz.procedureengine.KnowledgeAgentTest$ResourcePoller.run(KnowledgeAgentTest.java:68)
           at java.lang.Thread.run(Thread.java:680)