NPE in Drools JPA Persistence with rules that use Flow
by Shannon Hastings
I am using drools 5.2.0.M2 and I still get this error:
Caused by: java.lang.NullPointerException
at org.drools.marshalling.impl.InputMarshaller.readLeftTuple(InputMarshaller.java:469)
Which was reported on drools 5.1.0 JIRA and claimed to be fixed. I see the error when trying to load a session that was persisted that had objects inserted that are time depended and cause rules to fire that use terms from flow such as "after". I only see this error if create a new session, submit some facts to it, close it, and then try to reload. If i do not submit any facts to it I do not get the error. I.E. If all i do is create the KB with my rules I can reload a session from the DB no problem, but if i submit some facts and persist the session, then i cannot reload it. This seems to be an issue with the JPA loading of the session that has facts in it that use Flow (JBPM). Any help would be greatly appreciated. Below are my simple rules followed by the test code used to submit the facts:
package com.inventrio.rules.readings
import com.inventrio.healthmonitoring.model.*;
declare Reading
@role(event)
@timestamp(readingTime)
end
rule "High Blood Pressure"
when
$eventA : Reading(readingType.name == "BPMETER")
$systolic : Value( this.valueType.name == "SYSTOLIC" ) from $eventA.values
$diastolic : Value( this.valueType.name == "DIASTOLIC" ) from $eventA.values
eval( $systolic.getLongValue() > 180 && $diastolic.getLongValue() > 120 )
then
System.out.println("HIGH BLOOD PRESSURE" );
end
rule "Weight Trending Up"
when
$eventC : Reading(readingType.name == "WEIGHT" )
$eventB : Reading( readingType.name == "WEIGHT" , this after[5s, 1m] $eventC )
$eventA : Reading( readingType.name == "WEIGHT" , this after[5s, 1m] $eventB )
$weight3 : Value( this.valueType.name == "WEIGHT" ) from $eventC.values
$weight2 : Value( this.valueType.name == "WEIGHT" ) from $eventB.values
$weight1 : Value( this.valueType.name == "WEIGHT" ) from $eventA.values
eval( $weight3.getDoubleValue().doubleValue() < $weight2.getDoubleValue().doubleValue() + 1.0 && $weight2.getDoubleValue().doubleValue() < $weight1.getDoubleValue().doubleValue() + 1.0 )
then
System.out.println("WEIGHT IS GOING UP" );
end
rule "Weight Trending Down"
when
$eventC : Reading(readingType.name == "WEIGHT" )
$eventB : Reading( readingType.name == "WEIGHT" , this after[5s, 1m] $eventC )
$eventA : Reading( readingType.name == "WEIGHT" , this after[5s, 1m] $eventB )
$weight3 : Value( this.valueType.name == "WEIGHT" ) from $eventC.values
$weight2 : Value( this.valueType.name == "WEIGHT" ) from $eventB.values
$weight1 : Value( this.valueType.name == "WEIGHT" ) from $eventA.values
eval( $weight3.getDoubleValue().doubleValue() > $weight2.getDoubleValue().doubleValue() + 1.0 && $weight2.getDoubleValue().doubleValue() > $weight1.getDoubleValue().doubleValue() + 1.0 )
then
System.out.println("WEIGHT IS GOING DOWN" );
end
And next is my object i insert before closeing and then trying to reload the session.
public void testWeightRules() {
try {
Reading reading = new Reading();
reading.setReadingTime(new Date(System.currentTimeMillis()));
ReadingType type = new ReadingType();
type.setName("WEIGHT");
type.setDescription("");
reading.setReadingType(type);
Value value = new Value();
value.setDoubleValue(140.0);
ValueType valueType = new ValueType();
valueType.setName("WEIGHT");
valueType.setDataType(ValueDataType.DOUBLE);
value.setValueType(valueType);
reading.getValues().add(value);
reading.setReadingType(type);
engine.process(reading);
Thread.sleep(7000);
reading = new Reading();
reading.setReadingTime(new Date(System.currentTimeMillis()));
type = new ReadingType();
type.setName("WEIGHT");
type.setDescription("");
reading.setReadingType(type);
value = new Value();
value.setDoubleValue(142.0);
valueType = new ValueType();
valueType.setName("WEIGHT");
valueType.setDataType(ValueDataType.DOUBLE);
value.setValueType(valueType);
reading.getValues().add(value);
reading.setReadingType(type);
engine.process(reading);
Thread.sleep(7000);
reading = new Reading();
reading.setReadingTime(new Date(System.currentTimeMillis()));
type = new ReadingType();
type.setName("WEIGHT");
type.setDescription("");
reading.setReadingType(type);
value = new Value();
value.setDoubleValue(144.0);
valueType = new ValueType();
valueType.setName("WEIGHT");
valueType.setDataType(ValueDataType.DOUBLE);
value.setValueType(valueType);
reading.getValues().add(value);
reading.setReadingType(type);
engine.process(reading);
} catch (Throwable t) {
t.printStackTrace();
}
}
Shannon Hastings
Inventrio
545 Metro Place South, Suite 475
Dublin, OH 43017
Phone: (614) 389-2795 x101
Fax: (614) 522-6249
Email: shannon.hastings(a)inventrio.com
http://www.inventrio.com
14 years, 7 months
Re: [rules-users] [rules-dev] Two Day Drools and jBPM Workshop (Argentina June)
by Mauricio Salatino
Yeah! it's an unique opportunity for the people in Argentina to see most of
the team together in the same place!
On Thu, May 26, 2011 at 8:34 AM, Pablo Elo <elo(a)intalio.com> wrote:
> What a good news! I will be there for sure.
>
> On Wed, May 25, 2011 at 10:24 AM, Mark Proctor <mproctor(a)codehaus.org>wrote:
>
>> http://blog.athico.com/2011/05/2-day-drools-and-jbpm-workshop.html
>>
>> Thanks to OSDE we now have a 2 day workshop planned in Argetina for June,
>> with nearly all the core drools and jbpm developers. A MUST attend event for
>> any developer in South America.
>>
>> We are just finalising locations, agendas and speakers, we'll give more
>> firm details later, but initially the line up is as follows:
>>
>> Where: Argentina (Buenos Aries)
>> Date: 16-17 June (Thu/Fri)
>>
>> Speakers:
>> Mark Proctor - Group Lead and Drools co-founder
>> Kris Verlaenen - jBPM Lead
>> Edson Tirelli - Drools tech Lead
>> Geoffrey De Smet - Planner Lead
>> Michael Anstis - Business Tooling tech lead
>> Ray Ploski - Solutions Architect
>>
>> Guest Speakers (so far)
>> Salatino Mauricio (Plugtree)
>>
>> While us core developers will be focusing on Drools and jBPM, Ray will be
>> there to do talks on AS7, Seam and Infinispan.
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
>
> --
> Pablo Elo.
> Developer at Intalio Argentina.
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
14 years, 7 months
Avoiding log or error messages on console
by Manuel Ortiz
Hi everybody:
I'm developing a Drools based application which has to show no messages on
console, but on log files or so. I've diverted these kind of messages to a
log file, but there is one at the beginning of the application, when the
change set is read...
(null: 6, 188): cvc-elt.1: Cannot find the declaration of element
'change-set'.
... which still appears on console.
I've read that this message doesn't affect rule engine behaviour, but I
would like it not to be shown on console.
Does anybody know how can I solve this problem?
Thank you in advance.
Best regards,
Manuel Ortiz.
14 years, 7 months
Concatenating rule conditions
by Hezi Stern
I have a rule that filters an ArrayList based on dynamic filtering
conditions, for example this list can be a set of documents and the filter
can be a user property which is required later for document filling (e.g.
private name).
This is fairly strait forward, where I can perform something of the sort:
Rule "test filter"
When
$cm: ConditionMatrix(),
$document: ArrayList() from collect ( Document
(user.isPrivateName == $cm.isPrivateName) )
Then
//do something
End
Now comes my question: I have a different rule that holds a different set of
filter requirements that works on Document object.
For example
Rule "test filter 2"
When
$cm: ConditionMatrix(),
$document: ArrayList() from collect ( Document
(Payment.isLegal == $cm.isLegal) )
Then
//do something
End
Is there any way to combine them both?
Thanks
Hezi
14 years, 7 months
Two Day Drools and jBPM Workshop (Argentina June)
by Mark Proctor
http://blog.athico.com/2011/05/2-day-drools-and-jbpm-workshop.html
Thanks to OSDE we now have a 2 day workshop planned in Argetina for
June, with nearly all the core drools and jbpm developers. A MUST attend
event for any developer in South America.
We are just finalising locations, agendas and speakers, we'll give more
firm details later, but initially the line up is as follows:
Where: Argentina (Buenos Aries)
Date: 16-17 June (Thu/Fri)
Speakers:
Mark Proctor - Group Lead and Drools co-founder
Kris Verlaenen - jBPM Lead
Edson Tirelli - Drools tech Lead
Geoffrey De Smet - Planner Lead
Michael Anstis - Business Tooling tech lead
Ray Ploski - Solutions Architect
Guest Speakers (so far)
Salatino Mauricio (Plugtree)
While us core developers will be focusing on Drools and jBPM, Ray will
be there to do talks on AS7, Seam and Infinispan.
14 years, 7 months
Drools and mobile
by Leonardo Gomes
Since I'm really a noobie on mobile development, this may be a stupid
question, but it doesn't hurt to ask: Does anybody here ever used Drools on
a mobile application? Would its dependencies allow it to be run on an
Android or Blackberry?
Basically, my idea is that with the CEP stuff added on Drools 5, it would be
interesting to capture events generated by the device and do some analysis.
Waiting on your feedback :)
Thanks,
- Leonardo.
14 years, 7 months
Update function usage for java objects to be retrieved for database update
by dbfree75
Hello,
I'm new with Drools and I'm facing a problem I don't know how to solve.
I've defined several (>50 rules) each one is used to set a property of java
objects I inserted in the session (stateful session since I need to update
inserted facts).
As a result I get the updated objects and update my database.
Since rules must be fired depending of the properties set in previous rules,
I made use of the update function.
Since I need properties to be set, I make use of such constraint in When
section : property == null
I suppose that any update on inserted facts make rules be evaluated again.
Thus, any update should fire again rules I know that will never be executed
: property will remain null (I didn't manage easily to create excluding
rules preventing such loop for all created rules).
Consequently, rules are fired again and again as many times as I update the
object.
How can I solve my problem and get acceptable perfomance in rules processing
?
Should I use update function for any property set or only for the last set
property to get the updated object ?
Thanks for your reply
--
View this message in context: http://drools.46999.n3.nabble.com/Update-function-usage-for-java-objects-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 7 months