Dear Drools users,
Apparently it was not caused by the previously mentioned fix. Sometimes
I still had a KnowledgeAgent in my server that doesn't respond anymore
which seems to be caused by a mistake in the DRL file.
I started to investigate the source code of KnowledgeAgentImpl and
KnowledgeBaseImpl and recompiled them to add some prints. Finally I
tracked it until AbstractRuleBase.addPackages.
There is a giant Try-final block and I noticed by adding prints that it
stopped somewhere in the middle. When it does fail, my KnowledgeAgent
stops working completely.
The try-final seemed to be the only place for me where an exception
might be ignored so I added a catch clause.
As a result, the error report of my drl file was nicely printed and my
agent didn't crash:
*org.drools.RuntimeDroolsException: Unable to resolve class 'int' for
global 'RULES_MATCHED'
at
org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:818)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:615)
at
org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:472)
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:153)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1173)
at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:1058)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:738)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:259)
at
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1357)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
*
Maybe there is a reason for this missing catch so I am not sure whether
I fixed it and broke something else ( eg. maybe I should undo a part of
the operations before I continue).
Is there anyone who knows this code and who can help me?
Extra information:
- I use Drools 5.5 from the Maven repository.
- my agent configuration:
agentConf.setProperty("drools.agent.newInstance",
"false");
agentConf.setProperty("drools.agent.useKBaseClassLoaderForCompiling",
"true");
Kind Regards,
De Rooms Brecht
Op 31/07/2013 14:45, De Rooms Brecht schreef:
The bug was caused by one of the InputStreams that was not closed
properly which caused the knowledgeAgent to block.
I think my issues are solved now.
Thanks for looking into this.
Kind Regards,
Op 31/07/2013 14:19, De Rooms Brecht schreef:
> Hello David and thanks for responding.
> I know it supports these event listeners and I use them. In my
> program, I have two knowledge agents and the first one
> (preprocessing) will read the file, preprocess a DRL and then write a
> second modified DRL file in a folder that is monitored by the second
> one. When I modify the original DRL file *(1.* in prints below*)*
> monitored by the preprocessing agent, everything works fine and the
> rule is triggered*(**2.)*. However, when I delete a file *(**3.)*,
> the knowledgeAgent just blocks after AfterChangeSetAppliedEvent and
> does not do anything anymore.. If I send new data in the
> knowledgeAgent it does not react anymore.
>
> I would expect to get a stacktrace of what went wrong but I do not
> get any info besides of the systemeventlistener or
> knowledgeagentlistener. Is there any way I can get a stacktrace?
> Kind Regards,
> De Rooms Brecht
>
> _*1. Resources Changed => Modified: [[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']]*_
> / eventListener 1:::
> ==>[BeforeResourceProcessedEvent(RESOURCE_REMOVED): [FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']]//
> // eventListener 1:::
> ==>[AfterResourceProcessedEvent(RESOURCE_REMOVED): [FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']]//
> // eventListener 1::: ==>[AfterChangeSetProcessedEvent:
> ChangeSetImpl{resourcesRemoved=[], resourcesAdded=[],
> resourcesModified=[[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 1::: ==>[ResourceCompilationFailedEvent:
> org.drools.builder.impl.KnowledgeBuilderImpl@70d0d127]//
> // eventListener 1::: ==>[KnowledgeBaseUpdatedEvent:
> org.drools.impl.KnowledgeBaseImpl@49669be]//
> // eventListener 1::: ==>[AfterChangeSetAppliedEvent:
> ChangeSetImpl{resourcesRemoved=[], resourcesAdded=[],
> resourcesModified=[[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 2::: ==>[BeforeChangeSetAppliedEvent:
> ChangeSetImpl{resourcesRemoved=[], resourcesAdded=[],
> resourcesModified=[[FileResource
> file='knowledge\packaged\test.brules.testRule.drl']],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 2:::
> ==>[BeforeResourceProcessedEvent(RESOURCE_REMOVED): [FileResource
> file='knowledge\packaged\test.brules.testRule.drl']]//
> // eventListener 2:::
> ==>[AfterResourceProcessedEvent(RESOURCE_REMOVED): [FileResource
> file='knowledge\packaged\test.brules.testRule.drl']]//
> // eventListener 2::: ==>[AfterChangeSetProcessedEvent:
> ChangeSetImpl{resourcesRemoved=[], resourcesAdded=[],
> resourcesModified=[[FileResource
> file='knowledge\packaged\test.brules.testRule.drl']],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 2::: ==>[KnowledgeBaseUpdatedEvent:
> org.drools.impl.KnowledgeBaseImpl@11c834d1]/
>
> _*2. Rules are triggered when the PKG file its knowledge is updated:*_
> / Changed This Rule::: Got Event: TestEvent( number=5,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=4,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=2,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=1,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=2,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=1,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=2,
> message=doesDynamicEventTypeWork? )//
> // Changed This Rule::: Got Event: TestEvent( number=1,
> message=doesDynamicEventTypeWork? )//
> //
> // eventListener 2::: ==>[AfterChangeSetAppliedEvent:
> ChangeSetImpl{resourcesRemoved=[], resourcesAdded=[],
> resourcesModified=[[FileResource
> file='knowledge\packaged\test.brules.testRule.drl']],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 1::: ==>[BeforeChangeSetAppliedEvent:
> ChangeSetImpl{resourcesRemoved=[[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']],
> resourcesAdded=[], resourcesModified=[],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 1::: ==>[BeforeChangeSetProcessedEvent:
> ChangeSetImpl{resourcesRemoved=[[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']],
> resourcesAdded=[], resourcesModified=[],
> knowledgeDefinitionsRemoved=[]}]/
>
>
> _*3. *__*Resources Changed => *__*Removed: [[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']]*_
> / eventListener 1:::
> ==>[BeforeResourceProcessedEvent(RESOURCE_MODIFIED): [FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']]//
> // eventListener 1:::
> ==>[AfterResourceProcessedEvent(RESOURCE_MODIFIED): [FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']]//
> // eventListener 1::: ==>[AfterChangeSetProcessedEvent:
> ChangeSetImpl{resourcesRemoved=[[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']],
> resourcesAdded=[], resourcesModified=[],
> knowledgeDefinitionsRemoved=[]}]//
> // eventListener 1::: ==>[KnowledgeBaseUpdatedEvent:
> org.drools.impl.KnowledgeBaseImpl@49669be]//
> // eventListener 1::: ==>[AfterChangeSetAppliedEvent:
> ChangeSetImpl{resourcesRemoved=[[FileResource
> file='knowledge\realtimeKnowledge\test.brules.testRule.drl']],
> resourcesAdded=[], resourcesModified=[],
> knowledgeDefinitionsRemoved=[]}]/
>
> .... and then it was quiet....
>
> Op 31/07/2013 09:42, Davide Sottara schreef:
>> The KA logs to a SystemEventListener, and supports a dedicated event
>> listener for
>> additions/updates/etc...
>>
>> You can do:
>>
>> kagent.setSystemEventListener( new PrintStreamSystemEventListener() );
>> kagent.addEventListener( new DebugKnowledgeAgentEventListener( ) );
>>
>>
>>
>> On 07/30/2013 01:55 AM, De Rooms Brecht wrote:
>>> Dear Drools users,
>>>
>>> I have been testing with the KnowledgeAgent from version 5.4 and 5.5. It
>>> monitors a changeset and is set to incrementally build the
>>> knowledgebase. I noticed that it sometimes crashes but never throws out
>>> errors. This happens for example when I define a type two times and when
>>> I remove a file. Does anyone experience similar behaviour and has an
>>> idea of how I could see the errors? I already tried to check the errors
>>> by building it myself using a knowledgebuilder before I update the file
>>> that the knowledgeAgent monitors but that's quite a dirty solution.
>>>
>>> Kind Regards,
>>> De Rooms Brecht
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users