[rules-users] NPE for any @role( event )

capn_ed cncosper at capn-ed.net
Tue Jan 24 12:36:05 EST 2012


Thank you very much. That seems to do the trick.

I was going to say that the call to add knowledge packages wasn't in the
Drools Expert User Guide example, but looking back at the User Guide, I see
that it IS there in the example setup. I also see that in my previous
project, which did not use events, I had that call, but commented it out for
some reason. As far as I am able to determine, though, for the fact-based
setup, that call didn't make any difference. It worked just as well without
it. And the Drools Fusion User Guide doesn't give an example for setting up
the knowledge base/builder/session/etc.


For the benefit of those who might be searching for a similar problem:

When I started with an event-based drl file, I began by copying my existing
(working) project and modifying it to use the stream processing mode. There
was some hints about how to do this in the Drools Fusion documentation, but
it wasn't complete. The implication is that the setup that is shown in the
Drools Expert User Guide example should be used. That example was:

Create a knowledge builder.
Add resources to the knowledge builder. 
Check for errors.
Create a knowledge base from the builder.
Add knowledge packages to the knowledge base, (which step I skipped, but
didn't notice.)

The Drools Fusion User Guide says to create a KnowledgeBaseConfiguration
object, and set the options desired, but doesn't give a clue about what to
do with it after that. I initially assumed that it would be passed in an
overloaded form of the KnowledgeBuilder getKnowledgeBase() method, but no
such overload exists. By examining the available methods, I found an
overload of KnowledgeBaseFactory.newKnowledgeBase() that took a
KnowledgeBaseConfiguration object, but then I had to re-order my
initialization steps, because I had the KnowledgeBase before I created the
KnowledgeBuilder:

Create a KnowledgeBaseConfiguration object.
Set the options desired.
Create a KnowledgeBase using KnowledgeBaseFactory.newKnowledgeBase(),
passing in the config object.
Create a KnowledgeBuilder using
KnowledgeBuilderFactory.newKnowledgeBuilder() passing in the KnowledgeBase
object.
Add resources to the builder.
Check for errors.
And, the step that I forgot, Add knowledge packages to the knowledge base.

Without the final step, things seemed to work correctly as long as I didn't
include @role( event ).

--
View this message in context: http://drools.46999.n3.nabble.com/NPE-for-any-role-event-tp3683063p3685458.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list