Today I've reported a similar (?) problem with KnowledgeAgent ind
combination with declare: the type of the inserted wasn't recognized, and
rules didn't fire.
Please check that this produces the correct class name:
rule justTestClass
salience 1000000
when
then
Event event = new Event();
System.out.println( event.getName() );
// insert( event );
end
If it does, uncomment and try again: Does insert work from DRL?
-W
2012/2/10 Joaquín Díaz Vélez <joaquin.diazvelez(a)fluxit.com.ar>
W, thanks for your reply. The Event fields are all complete and
initialized. If I change the rule package to the one in Event (let's say
"package-name(rule) == package-name(Event)") everything works like a charm.
I'll give you more details about the NPE.
Happends in this class: org.drools.reteoo.ReteooFactHandleFactory, method:
protected final InternalFactHandle newFactHandle(final int id,
final Object object,
final long recency,
*final
ObjectTypeConf conf,*
final
InternalWorkingMemory workingMemory,
final
WorkingMemoryEntryPoint wmEntryPoint) {
if ( conf != null && conf.isEvent() ) {
* TypeDeclaration type = conf.getTypeDeclaration();*
long timestamp;
* if ( type.getTimestampExtractor() != null ) { --> NPE here,
because type is null*
if ( Date.class.isAssignableFrom(
type.getTimestampExtractor().getExtractToClass() ) ) {
timestamp = ((Date)
type.getTimestampExtractor().getValue( workingMemory,
object )).getTime();
(...) etc
}
So, *type *is null (shouldn't be). I debugged the execution and I found
that ObjectTypeConfigurationRegistry is holding this instance of *conf.*
Any ideas?
Thanks in advance
2012/2/9 Wolfgang Laun <wolfgang.laun(a)gmail.com>
> The NPE during insertion is highly suggestive of another problem. Even if
> there were two Event classes (one the pojo, the other one the declared one)
> there should not be a NPE; the "hello world" rule simply would not fire.
> Are all fields - especially eventName - properly initialized before that
> fact is inserted?
>
> -W
>
> 2012/2/9 Joaquín Díaz Vélez <joaquin.diazvelez(a)fluxit.com.ar>
>
>> Hi guys,
>>
>> we are currently working with Drools Fusion in order to
>> build a complex event processing solution. We've modelled our events using
>> and object (Event) and this object is shared with everyone that needs to
>> publish and event.
>>
>> Our scenario goes this way
>>
>> 1) Our shared class, located in *ar.com.fluxit.Event*
>>
>> 2) An example of our cep rules declared in package *rules.flux*
>>
>> package *rules.flux*
>>
>> import *ar.com.fluxit.Event;*
>>
>> declare *Event*
>> @role (event)
>> @expires(1m)
>> end
>>
>> rule "hello world"
>> when
>> $event:Event( eventName == "Hello World") from entry-point "*
>> rules.flux*"
>> then
>> System.out.println("Hello world");
>> end
>>
>>
>> 3) When we try to insert a *ar.com.fluxit.Event *as a fact in entry
>> point "rules.flux" Drools Fusion throws a NullPointerException. If you
read
>> Drools Expert documentation (
>>
http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/...
>> -
>> Accessing Declared Types from the Application Code) you find this
>> paragraph:
>> "The first important thing to realize is that a declared fact will
>> belong to the package where it was declared. So, for instance, in the
>> example below, Person will belong to the org.drools.examples package,
>> and so the fully qualified name of the generated class will be
>> org.drools.examples.Person."
>>
>> When we change package declaration to *package ar.com.fluxit *everything
>> works like a charm. But in our cep scenario we need that our
>> ar.com.fluxit.Event object to be user by all rules declared in any package.
>>
>> So, there goes the question. There is a workaround for this? This is a
>> bug?
>>
>> Any help would be very appreciated
>>
>>
>> Cheers
>>
>>
>> --
>> Joaquín Díaz Vélez
>>
>> Flux IT SA
>> Calle 9 N° 865 - Paseo La Panadería - Planta Alta
>> La Plata - Buenos Aires - Argentina
>> Teléfono (+54) 221 553 2980 int 306
>> Móvil (+54) 9221 5863322
>>
www.fluxit.com.ar
>>
>>
>>
>> _______________________________________________
>> 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
>
>
--
Joaquín Díaz Vélez
Flux IT SA
Calle 9 N° 865 - Paseo La Panadería - Planta Alta
La Plata - Buenos Aires - Argentina
Teléfono (+54) 221 553 2980 int 306
Móvil (+54) 9221 5863322
www.fluxit.com.ar
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users