Re: [rules-users] Declared Types and Globals in different files with incremental KnowledgeAgent

2013-09-23 Thread De Rooms Brecht

Op 20/09/2013 21:23, Davide Sottara schreef:

Brecht, thanks for reporting this, but I don't think these are bugs.

Thanks for the explanations. I tested it to be sure and it works as 
expected. The drools.agent.useKBaseClassLoaderForCompiling option 
indeed fixes the issue unless the agent detects several files at the 
same time in which case they are processed in alphabetical order (which 
is to be expected). In that case my preprocessing hack is still useful. 
The globals are just something different than what I expected globals to 
be.


Thank you very much for the support.
1) In order to set the value of a global from a rule's RHS, you have 
to do somehting like this


drools.getKnowledgeRuntime().setGlobal( RULES_MATCHED, newValue );

The reason is that the rule's RHS sees a reference to the original 
global... a local variable with the
same name initialized appropriately. Something like RULES_MATCHED = 0 
will only change the local

reference, not modify the global.

2) The KnowledgeAgent supports declared types incrementally.. (Esteban 
and I spent a lot of time to make

that work), but you have to set a flag in the KA's configuration:

KnowledgeAgentConfiguration aconf = 
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();

aconf.setProperty( drools.agent.useKBaseClassLoaderForCompiling, true );

The incremental mode (newInstance=false) only ensures that the 
existing KnowlegeBase is updated,
tue useKBaseClassLoaderForCompiling will ALSO make sure that, as the 
new resources are compiled
by a KnowledgeBuilder, this is initialized with the KB's classloader, 
which has the classes for the declared types.


3) I have proposed a fix for the issue you reported the other day... 
actually two in one.

- 3a ) Runtime exceptions will be catched,
- 3b ) you **WILL NOT** be able to use primitive types with globals 
anymore.. (which would result in a RTE anyway)


Hope this help
Best
Davide



On 09/20/2013 02:18 AM, De Rooms Brecht wrote:

Dear Drools Users,

I am building a network server for drools  since the existing 
drools-server did not meet my requirements.  Since I recently found a 
bug and find the people here very helpful I'll try to explain another 
issue I encountered in the hope that it improves drools 5.6 and 6.0.
I noticed that declared types and globals don't seem to be found when 
you access them from a rule that was written in a different file. For 
the declared types I hacked around this issue by preprocessing the 
files and placing every declared type at the top of each file that 
needs it. For globals this is of course not possible.


An example is shown below. File1 is loaded from the moment the agent 
starts up, then file2 is loaded.
There is a difference when the knowledgeAgent detects the two files 
at once or one by one. In this case the KnowledgeAgent detects one 
file and then a few minutes later the other file and compiles them 
completely separately.
The idea is to keep how many rules are matched of a certain type in a 
global.


*   FILE1: global_rules_matches.drl
--
package ellipsoidfacts

// declare
global Integer RULES_MATCHED;

// initialize global
rule initRULESMATCHED
  salience 999
  when

  then
  RULES_MATCHED = 0;
end*

*   FILE2: testrule.drl
--
package ellipsoidfacts

   rule Gesture_lefthook
when

// ... any  precedent rules ...

then
System.out.println(matched gesture:  lefthook+ RULES_MATCHED);
end*

In this particular case, my rule is not matched. I load these rules 
using a changeset xml, my knowledgeagent is set to incremental (but 
either doesnt work).
The same happens when I declare types in FILE1 and use them in FILE2. 
When I write the type declaration in both files it works perfectly.
Being the same package I assumed that these two scenarios should 
work. Am I doing something wrong or is the agent not supposed to work 
like this and should a package be in one file?


Kind Regards,
De Rooms Brecht


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
Brecht De Rooms
=
Phd Student
Vrije Universiteit Brussel
Research Group CISA(WISE) - DINF F.10.707
Department of Computer Science
Pleinlaan 2   - 1050 Brussels - Belgium
Tel. +32-2-629 1103
E-mail: bdero...@vub.ac.be
Website  http://wise.vub.ac.be/brecht-de-rooms
=

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

[rules-users] Declared Types and Globals in different files with incremental KnowledgeAgent

2013-09-20 Thread De Rooms Brecht

Dear Drools Users,

I am building a network server for drools  since the existing 
drools-server did not meet my requirements.  Since I recently found a 
bug and find the people here very helpful I'll try to explain another 
issue I encountered in the hope that it improves drools 5.6 and 6.0.
I noticed that declared types and globals don't seem to be found when 
you access them from a rule that was written in a different file. For 
the declared types I hacked around this issue by preprocessing the files 
and placing every declared type at the top of each file that needs it. 
For globals this is of course not possible.


An example is shown below. File1 is loaded from the moment the agent 
starts up, then file2 is loaded.
There is a difference when the knowledgeAgent detects the two files at 
once or one by one. In this case the KnowledgeAgent detects one file and 
then a few minutes later the other file and compiles them completely 
separately.
The idea is to keep how many rules are matched of a certain type in a 
global.


*   FILE1: global_rules_matches.drl
--
package ellipsoidfacts

// declare
global Integer RULES_MATCHED;

// initialize global
rule initRULESMATCHED
  salience 999
  when

  then
  RULES_MATCHED = 0;
end*

*   FILE2: testrule.drl
--
package ellipsoidfacts

   rule Gesture_lefthook
when

// ... any  precedent rules ...

then
System.out.println(matched gesture:  lefthook+ RULES_MATCHED);
end*

In this particular case, my rule is not matched. I load these rules 
using a changeset xml, my knowledgeagent is set to incremental (but 
either doesnt work).
The same happens when I declare types in FILE1 and use them in FILE2. 
When I write the type declaration in both files it works perfectly.
Being the same package I assumed that these two scenarios should work. 
Am I doing something wrong or is the agent not supposed to work like 
this and should a package be in one file?


Kind Regards,
De Rooms Brecht
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] No errors thrown from KnowledgeAgent

2013-09-19 Thread De Rooms Brecht

Dear Davide

thank you very much for looking into this.
I was wondering, are these kind of bugs also there in the commercial 
edition or is that a completely different implementation?


Kind Regards,
De Rooms Brecht

Op 19/09/2013 10:46, Davide Sottara schreef:
It is a bug, the KA can detect compilation errors in resources, but 
will not capture runtime exceptions.

I have opened a ticket, It will be fixed in 5.6 and 6.x
Davide

On 09/17/2013 01:51 PM, De Rooms Brecht wrote:

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

Re: [rules-users] No errors thrown from KnowledgeAgent

2013-09-17 Thread De Rooms Brecht

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

Re: [rules-users] No errors thrown from KnowledgeAgent

2013-07-31 Thread De Rooms Brecht

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

Re: [rules-users] No errors thrown from KnowledgeAgent

2013-07-31 Thread De Rooms Brecht
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

Re: [rules-users] uninformative rule parsing/compiling error - org.drools.rule.Rule cannot be cast to org.drools.rule.Query

2013-07-30 Thread De Rooms Brecht

Op 24/07/2013 14:24, Davide Sottara schreef:

Two clarifications first:

1) Which version are you using?

I am using version 5.5

2) Is TrackerUpdate a static class inside TrackerRemote?
In case, could you post the exact import statements you are using?

the TrackerUpdate is not static, but it's a class defined within the 
TrackerUpdate class.

/public class TrackerRemote

 public class TrackerUpdate {
public java.util.Date msg_time;
public int sensor;
public double[] pos;
public double[] quat;

public TrackerUpdate() { /* compiled code */ }
}/

The full imports and rule is:
package derooms.be.testRule
import derooms.be.server.predefinedtypes.Event;
import derooms.be.test.Message;
import vrpn.TrackerRemote;
/
rule TrackerRemote.TrackerUpdate
when
message:TrackerRemote.TrackerUpdate()
then
System.out.println(Tracker:  + message);
end/

Sorry that I didn't sent it earlier, I actually sent this e-mail already 
but it didn't came through.


B


Thanks
Davide

On 07/24/2013 02:14 PM, De Rooms Brecht wrote:

Dear rules users,

I am currently writing my own Drools-server since I wanted more 
control than the drools-execution server (and it never worked very 
well here) where I can send rules/facts over JMS/AQMP/STOMP. Rules 
which are sent are saved on the server-side in DRL files that are 
monitored. That way, I can debug easily by changing the sent files. 
However, when I sent the following code, the agent does not provide 
me with an error message at all and hangs:

/
//rule TrackerRemote.TrackerUpdate//
//when//
//message:TrackerRemote.TrackerUpdate()//
//then//
//System.out.println(Tracker:  + message);//
//end/

at first I thought it was because TrackerRemote.TrackerUpdate is not 
in that package anymore and thus unknown so I tried to send the rule 
listed below which gives me the nice and expected error:

Unable to resolve ObjectType 'NotExistingType' : [Rule name='Foo']

/rule Foo//
//when //
//NotExistingType( bloe == test)//
//then//
//System.out.println(this should not work);//
//end/

when I compile the rule myself with a KnowledgeBuilder:

KnowledgeBuilder kbuilder = 
KnowledgeBuilderFactory.newKnowledgeBuilder();

InputStream is = new ByteArrayInputStream(drlstring.getBytes());
kbuilder.add( 
ResourceFactory.newInputStreamResource(is),ResourceType.DRL );


I receive the error:
org.drools.rule.Rule cannot be cast to org.drools.rule.Query
which I think doesn't tell me anything about the mistake I made in my 
rule, is this a Drools bug and should I post this somewhere?


Kind Regards,
De Rooms Brecht


Full Stack:
java.lang.ClassCastException: org.drools.rule.Rule cannot be cast to 
org.drools.rule.Query
at 
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:175)
at 
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:118)
at 
org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:67)

at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:84)
at 
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2706)
at 
org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:930)
at 
org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:839)
at 
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
at 
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:467)
at 
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:673)
at 
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at 
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at 
derooms.be.server.listeners.RulesListener.processMessage(RulesListener.java:33)
at 
derooms.be.server.listeners.AbstractListener.onMessage(AbstractListener.java:35)
at 
org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
at 
org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
at 
org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
at 
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
at 
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
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)


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users

[rules-users] No errors thrown from KnowledgeAgent

2013-07-30 Thread De Rooms Brecht
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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] uninformative rule parsing/compiling error - org.drools.rule.Rule cannot be cast to org.drools.rule.Query

2013-07-25 Thread De Rooms Brecht
Op 24/07/2013 14:24, Davide Sottara schreef:
 Two clarifications first:

 1) Which version are you using?

Version 5.4.0.Final
 2) Is TrackerUpdate a static class inside TrackerRemote?
 In case, could you post the exact import statements you are using?

It is a normal class inside TrackerRemote.
   public class TrackerRemote extends vrpn.VRPNDevice implements 
java.lang.Runnable {
  public class TrackerUpdate {...

I imported:
import vrpn.TrackerRemote;

and used it as follows:
rule TrackerRemote.TrackerUpdate
 when
 message:TrackerRemote.TrackerUpdate()
 then
 System.out.println(Tracker:  + message);
end

Extra information:
I have been trying to add type declarations in one file and import them 
in another and I get exactly the same error message. There I did this:
 package derooms.be.testRule
 declare TestEvent
@typesafe(false)
number : int
message : String
 end

and then a rule:
   package derooms.be.testRule
   rule TestEvent
 when
 event:TestEvent(message == doesDynamicEventTypeWork?)
 then
 System.out.println(Got Event:  + event.data);
 end



___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] uninformative rule parsing/compiling error - org.drools.rule.Rule cannot be cast to org.drools.rule.Query

2013-07-24 Thread De Rooms Brecht

Dear rules users,

I am currently writing my own Drools-server since I wanted more control 
than the drools-execution server (and it never worked very well here) 
where I can send rules/facts over JMS/AQMP/STOMP. Rules which are sent 
are saved on the server-side in DRL files that are monitored. That way, 
I can debug easily by changing the sent files. However, when I sent the 
following code, the agent does not provide me with an error message at 
all and hangs:

/
//rule TrackerRemote.TrackerUpdate//
//when//
//message:TrackerRemote.TrackerUpdate()//
//then//
//System.out.println(Tracker:  + message);//
//end/

at first I thought it was because TrackerRemote.TrackerUpdate is not in 
that package anymore and thus unknown so I tried to send the rule listed 
below which gives me the nice and expected error:

Unable to resolve ObjectType 'NotExistingType' : [Rule name='Foo']

/rule Foo//
//when //
//NotExistingType( bloe == test)//
//then//
//System.out.println(this should not work);//
//end/

when I compile the rule myself with a KnowledgeBuilder:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
InputStream is = new ByteArrayInputStream(drlstring.getBytes());
kbuilder.add( ResourceFactory.newInputStreamResource(is),ResourceType.DRL );

I receive the error:
org.drools.rule.Rule cannot be cast to org.drools.rule.Query
which I think doesn't tell me anything about the mistake I made in my 
rule, is this a Drools bug and should I post this somewhere?


Kind Regards,
De Rooms Brecht


Full Stack:
java.lang.ClassCastException: org.drools.rule.Rule cannot be cast to 
org.drools.rule.Query
at 
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:175)
at 
org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:118)
at 
org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:67)

at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:84)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2706)
at 
org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:930)
at 
org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:839)
at 
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
at 
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:467)
at 
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:673)
at 
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at 
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at 
derooms.be.server.listeners.RulesListener.processMessage(RulesListener.java:33)
at 
derooms.be.server.listeners.AbstractListener.onMessage(AbstractListener.java:35)
at 
org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
at 
org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
at 
org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
at 
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
at 
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
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)
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users