Re: [rules-users] peephole technique - cast to java.lang.Number problem

2013-11-04 Thread Alexander Wolf
MVEL was my first suspect as well, but the same rules in java dialect (just 
added setters/getters)
produced same exceptions. 

Alex

On 04 Nov 2013, at 07:43, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 You never know what an expression suffers when it is thrown into
 the MVEL machinery, (Mario's continuing efforts notwithstanding).
 Documentation is sparse...
 
 To be on the safe side, I'd probably have written
 
 rule count old
 when
   $le : LastEvent($ev: event )
$last: Event( this == $ev )
   $old : Event( this before [1ms , 5s] $last )
 then
   System.out.println($old);
 end
 
 -W
 
 
 
 
 On 03/11/2013, Alexander Wolf m...@alexander-wolf.net wrote:
 Okey I got a little further: This works:
 
 rule count old
 when
  $le : LastEvent($ts : event.timestamp)
  $old : Event(this before [1ms , 5s] $ts)
 then
  System.out.println($old);
 end
 
 but then why does this not work ?!
 
 rule count old
 when
  $le : LastEvent($event : event)
  $old : Event(this before [1ms , 5s] $event.timestamp)
 then
  System.out.println($old);
 end
 
 To me this seems to be a bug, that occurs as soon as I set an event as
 member of a fact (the LastEvent) - implementing the peephole technique.
 At least I got it to do what I want...but not as niceley... as expected.
 
 -
 
 
 On 02 Nov 2013, at 18:11, Alexander Wolf m...@alexander-wolf.net wrote:
 
 Drools 5.5.0 + Fusion / stateful session / STREAM mode
 
 Hi,
 
 I try to improve my rules using peephole technique (Thanks @W)
 I think I got it right, but now I am stuck with a problem.
 
 I want to keep a reference to my latest inserted event. Problem:  the rule
 print old gives me an Exception (see below).
 I think the peephole itself works pretty well, but somehow my Event Object
 (POJO with: Date timestamp, int value) is making problems when I try to
 use before.  (see marked line, when commenting it out, the rules run
 alright)
 
 dialect mvel
 
 import java.util.Date
 import com.testmodel.Event
 
 
 //declarations
 declare Event
 @role(event)
 @timestamp( timestamp )
 end
 
 declare LastEvent
 event: Event
 end
 
 
 rule init
 when
 //once...
 then
 System.out.println(init);
 LastEvent l = new LastEvent();
 Event e = new Event();
 e.timestamp = new Date();
 e.value = 0;
 l.event = e;
 insert(l);
 end
 
 rule update LastEvent
 no-loop
 salience 99
 when
 $event : Event()
 $last : LastEvent()
 then
 System.out.println(update LastEvent);
 retract ($last) 
 LastEvent l = new LastEvent();
 l.event = $event;
 insert(l);
 end 
 
 
 rule count old
 when
 LastEvent($last : event)
 $old : Event(this before [0 , 5s] $last)   //  THIS IS EVIL?!
 then
 System.out.println($old);
 end
 
 My test code looks like this:
 
 Event event = new Event(new Date(), 1);
 ksession.insert(event);
 ksession.fireAllRules();
 
 //sleep  1+ sec
 Thread.sleep(1001);
 
 Event event2 = new Event(new Date(), 2);
 ksession.insert(event2);
 ksession.fireAllRules();
 
 
 And this is the Exception I get:
 
 Exception executing consequence for rule init in testEasierLife: [Error:
 drools.insert(l): com.testmodel.Event cannot be cast to java.lang.Number]
 [Near : {... System.out.println(init); }]
 ^
 [Line: 1, Column: 1]
 at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
 at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
 at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
 at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
 at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
 at com.Test.test(PeepholeTest.java:65)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
 at
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
 at
 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
 at
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
 at
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
 at 

Re: [rules-users] peephole technique - cast to java.lang.Number problem

2013-11-04 Thread Wolfgang Laun
Maybe s.o. can contradict, but in 5.5.0 (and even before) it's MVEL
for dealing with constraint expressions anyway, behind the scenes.

-W

On 04/11/2013, Alexander Wolf m...@alexander-wolf.net wrote:
 MVEL was my first suspect as well, but the same rules in java dialect (just
 added setters/getters)
 produced same exceptions.

 Alex

 On 04 Nov 2013, at 07:43, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 You never know what an expression suffers when it is thrown into
 the MVEL machinery, (Mario's continuing efforts notwithstanding).
 Documentation is sparse...

 To be on the safe side, I'd probably have written

 rule count old
 when
  $le : LastEvent($ev: event )
$last: Event( this == $ev )
  $old : Event( this before [1ms , 5s] $last )
 then
  System.out.println($old);
 end

 -W




 On 03/11/2013, Alexander Wolf m...@alexander-wolf.net wrote:
 Okey I got a little further: This works:

 rule count old
 when
 $le : LastEvent($ts : event.timestamp)
 $old : Event(this before [1ms , 5s] $ts)
 then
 System.out.println($old);
 end

 but then why does this not work ?!

 rule count old
 when
 $le : LastEvent($event : event)
 $old : Event(this before [1ms , 5s] $event.timestamp)
 then
 System.out.println($old);
 end

 To me this seems to be a bug, that occurs as soon as I set an event as
 member of a fact (the LastEvent) - implementing the peephole technique.
 At least I got it to do what I want...but not as niceley... as
 expected.

 -


 On 02 Nov 2013, at 18:11, Alexander Wolf m...@alexander-wolf.net
 wrote:

 Drools 5.5.0 + Fusion / stateful session / STREAM mode

 Hi,

 I try to improve my rules using peephole technique (Thanks @W)
 I think I got it right, but now I am stuck with a problem.

 I want to keep a reference to my latest inserted event. Problem:  the
 rule
 print old gives me an Exception (see below).
 I think the peephole itself works pretty well, but somehow my Event
 Object
 (POJO with: Date timestamp, int value) is making problems when I try to
 use before.  (see marked line, when commenting it out, the rules run
 alright)

 dialect mvel

 import java.util.Date
 import com.testmodel.Event


 //declarations
 declare Event
@role(event)
@timestamp( timestamp )
 end

 declare LastEvent
event: Event
 end


 rule init
 when
//once...
 then
System.out.println(init);
LastEvent l = new LastEvent();
Event e = new Event();
e.timestamp = new Date();
e.value = 0;
l.event = e;
insert(l);
 end

 rule update LastEvent
no-loop
salience 99
 when
$event : Event()
$last : LastEvent()
 then
System.out.println(update LastEvent);
retract ($last) 
LastEvent l = new LastEvent();
l.event = $event;
insert(l);
 end


 rule count old
 when
LastEvent($last : event)
$old : Event(this before [0 , 5s] $last)   //  THIS IS
 EVIL?!
 then
System.out.println($old);
 end

 My test code looks like this:

 Event event = new Event(new Date(), 1);
 ksession.insert(event);
 ksession.fireAllRules();

 //sleep  1+ sec
 Thread.sleep(1001);

 Event event2 = new Event(new Date(), 2);
 ksession.insert(event2);
 ksession.fireAllRules();


 And this is the Exception I get:

 Exception executing consequence for rule init in testEasierLife:
 [Error:
 drools.insert(l): com.testmodel.Event cannot be cast to
 java.lang.Number]
 [Near : {... System.out.println(init); }]
 ^
 [Line: 1, Column: 1]
at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at
 org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at
 org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.Test.test(PeepholeTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at
 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at
 

Re: [rules-users] peephole technique - cast to java.lang.Number problem

2013-11-03 Thread Alexander Wolf
Okey I got a little further: This works:  

rule count old
when
$le : LastEvent($ts : event.timestamp)
$old : Event(this before [1ms , 5s] $ts)
then
System.out.println($old);
end

but then why does this not work ?!

rule count old
when
$le : LastEvent($event : event)
$old : Event(this before [1ms , 5s] $event.timestamp)
then
System.out.println($old);
end

To me this seems to be a bug, that occurs as soon as I set an event as member 
of a fact (the LastEvent) - implementing the peephole technique. 
At least I got it to do what I want...but not as niceley... as expected.

- 
 

On 02 Nov 2013, at 18:11, Alexander Wolf m...@alexander-wolf.net wrote:

 Drools 5.5.0 + Fusion / stateful session / STREAM mode
 
 Hi,
 
 I try to improve my rules using peephole technique (Thanks @W)
 I think I got it right, but now I am stuck with a problem.
 
 I want to keep a reference to my latest inserted event. Problem:  the rule 
 print old gives me an Exception (see below). 
 I think the peephole itself works pretty well, but somehow my Event Object 
 (POJO with: Date timestamp, int value) is making problems when I try to use 
 before.  (see marked line, when commenting it out, the rules run alright)
 
 dialect mvel
 
 import java.util.Date
 import com.testmodel.Event
 
 
 //declarations
 declare Event
   @role(event)
   @timestamp( timestamp )
 end
 
 declare LastEvent
   event: Event
 end
 
 
 rule init
 when
   //once...
 then
   System.out.println(init);
   LastEvent l = new LastEvent();
   Event e = new Event();
   e.timestamp = new Date();
   e.value = 0;
   l.event = e;
   insert(l);
 end
   
 rule update LastEvent
   no-loop
   salience 99
 when
   $event : Event()
   $last : LastEvent()
 then
   System.out.println(update LastEvent);
   retract ($last) 
   LastEvent l = new LastEvent();
   l.event = $event;
   insert(l);
 end   
 
 
 rule count old
 when
   LastEvent($last : event)
   $old : Event(this before [0 , 5s] $last)   //  THIS IS EVIL?!
 then
   System.out.println($old);
 end
 
 My test code looks like this:
 
 Event event = new Event(new Date(), 1);
 ksession.insert(event);
 ksession.fireAllRules();
   
 //sleep  1+ sec
 Thread.sleep(1001);
   
 Event event2 = new Event(new Date(), 2);
 ksession.insert(event2);
 ksession.fireAllRules();
 
 
 And this is the Exception I get:
 
 Exception executing consequence for rule init in testEasierLife: [Error: 
 drools.insert(l): com.testmodel.Event cannot be cast to java.lang.Number]
 [Near : {... System.out.println(init); }]
  ^
 [Line: 1, Column: 1]
   at 
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
   at 
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
   at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
   at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
   at 
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
   at 
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
   at 
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
   at com.Test.test(PeepholeTest.java:65)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at 
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
   at 
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   at 
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
   at 
 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
   at 
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
   at 
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
   at 
 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at 
 

Re: [rules-users] peephole technique - cast to java.lang.Number problem

2013-11-03 Thread Wolfgang Laun
You never know what an expression suffers when it is thrown into
the MVEL machinery, (Mario's continuing efforts notwithstanding).
Documentation is sparse...

To be on the safe side, I'd probably have written

rule count old
when
$le : LastEvent($ev: event )
$last: Event( this == $ev )
$old : Event( this before [1ms , 5s] $last )
then
System.out.println($old);
end

-W




On 03/11/2013, Alexander Wolf m...@alexander-wolf.net wrote:
 Okey I got a little further: This works:

 rule count old
 when
   $le : LastEvent($ts : event.timestamp)
   $old : Event(this before [1ms , 5s] $ts)
 then
   System.out.println($old);
 end

 but then why does this not work ?!

 rule count old
 when
   $le : LastEvent($event : event)
   $old : Event(this before [1ms , 5s] $event.timestamp)
 then
   System.out.println($old);
 end

 To me this seems to be a bug, that occurs as soon as I set an event as
 member of a fact (the LastEvent) - implementing the peephole technique.
 At least I got it to do what I want...but not as niceley... as expected.

 -


 On 02 Nov 2013, at 18:11, Alexander Wolf m...@alexander-wolf.net wrote:

 Drools 5.5.0 + Fusion / stateful session / STREAM mode

 Hi,

 I try to improve my rules using peephole technique (Thanks @W)
 I think I got it right, but now I am stuck with a problem.

 I want to keep a reference to my latest inserted event. Problem:  the rule
 print old gives me an Exception (see below).
 I think the peephole itself works pretty well, but somehow my Event Object
 (POJO with: Date timestamp, int value) is making problems when I try to
 use before.  (see marked line, when commenting it out, the rules run
 alright)

 dialect mvel

 import java.util.Date
 import com.testmodel.Event


 //declarations
 declare Event
  @role(event)
  @timestamp( timestamp )
 end

 declare LastEvent
  event: Event
 end


 rule init
 when
  //once...
 then
  System.out.println(init);
  LastEvent l = new LastEvent();
  Event e = new Event();
  e.timestamp = new Date();
  e.value = 0;
  l.event = e;
  insert(l);
 end
  
 rule update LastEvent
  no-loop
  salience 99
 when
  $event : Event()
  $last : LastEvent()
 then
  System.out.println(update LastEvent);
  retract ($last) 
  LastEvent l = new LastEvent();
  l.event = $event;
  insert(l);
 end  


 rule count old
 when
  LastEvent($last : event)
  $old : Event(this before [0 , 5s] $last)   //  THIS IS EVIL?!
 then
  System.out.println($old);
 end

 My test code looks like this:

 Event event = new Event(new Date(), 1);
 ksession.insert(event);
 ksession.fireAllRules();
  
 //sleep  1+ sec
 Thread.sleep(1001);
  
 Event event2 = new Event(new Date(), 2);
 ksession.insert(event2);
 ksession.fireAllRules();


 And this is the Exception I get:

 Exception executing consequence for rule init in testEasierLife: [Error:
 drools.insert(l): com.testmodel.Event cannot be cast to java.lang.Number]
 [Near : {... System.out.println(init); }]
  ^
 [Line: 1, Column: 1]
  at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
  at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
  at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
  at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
  at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
  at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
  at com.Test.test(PeepholeTest.java:65)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at
 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at 

[rules-users] peephole technique - cast to java.lang.Number problem

2013-11-02 Thread Alexander Wolf
Drools 5.5.0 + Fusion / stateful session / STREAM mode

Hi,

I try to improve my rules using peephole technique (Thanks @W)
I think I got it right, but now I am stuck with a problem.

I want to keep a reference to my latest inserted event. Problem:  the rule 
print old gives me an Exception (see below). 
I think the peephole itself works pretty well, but somehow my Event Object 
(POJO with: Date timestamp, int value) is making problems when I try to use 
before.  (see marked line, when commenting it out, the rules run alright)

dialect mvel

import java.util.Date
import com.testmodel.Event


//declarations
declare Event
@role(event)
@timestamp( timestamp )
end

declare LastEvent
event: Event
end


rule init
when
//once...
then
System.out.println(init);
LastEvent l = new LastEvent();
Event e = new Event();
e.timestamp = new Date();
e.value = 0;
l.event = e;
insert(l);
end

rule update LastEvent
no-loop
salience 99
when
$event : Event()
$last : LastEvent()
then
System.out.println(update LastEvent);
retract ($last) 
LastEvent l = new LastEvent();
l.event = $event;
insert(l);
end 


rule count old
when
LastEvent($last : event)
$old : Event(this before [0 , 5s] $last)   //  THIS IS EVIL?!
then
System.out.println($old);
end

My test code looks like this:

Event event = new Event(new Date(), 1);
ksession.insert(event);
ksession.fireAllRules();

//sleep  1+ sec
Thread.sleep(1001);

Event event2 = new Event(new Date(), 2);
ksession.insert(event2);
ksession.fireAllRules();


And this is the Exception I get:

Exception executing consequence for rule init in testEasierLife: [Error: 
drools.insert(l): com.testmodel.Event cannot be cast to java.lang.Number]
[Near : {... System.out.println(init); }]
 ^
[Line: 1, Column: 1]
at 
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at 
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.Test.test(PeepholeTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: [Error: drools.insert(l): com.testmodel.Event cannot be cast to 
java.lang.Number]
[Near : {... System.out.println(init); }]
 ^
[Line: 1, Column: 1]
at