<bean id="rulesEngineManager"
class="com.inventrio.rules.engine.RulesEngineManagerImpl">
<constructor-arg ref="entityManagerFactory" index="0"></constructor-arg>
<constructor-arg ref="transactionManager" index="1"></constructor-arg>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql"
value="${com.inventrio.rules.engine.hibernate.showsql}" />
<property name="databasePlatform"
value="${com.inventrio.rules.engine.hibernate.dialect}" />
<property name="generateDdl" value="true" />
</bean>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
init-method="createDataSource" destroy-method="close">
<property name="driverClassName"
value="${com.inventrio.rules.engine.database.driver}" />
<property name="url" value="${com.inventrio.rules.engine.database.url}" />
<property name="username" value="${com.inventrio.rules.engine.database.user}" />
<property name="password"
value="${com.inventrio.rules.engine.database.password}" />
<property name="maxActive" value="30" />
<property name="maxIdle" value="10" />
<property name="maxWait" value="10000" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="300" />
<property name="logAbandoned" value="true" />
<property name="testWhileIdle" value="false" />
<property name="testOnReturn" value="true" />
<property name="validationQuery" value="select 1" />
<property name="timeBetweenEvictionRunsMillis" value="300000" />
<property name="minEvictableIdleTimeMillis" value="600000" />
</bean>
Persistance.xml snippit:
<persistence-unit name="org.drools.persistence.jpa"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>com.inventrio.rules.engine.SessionNameIdMapEntity</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
</persistence-unit>
On May 26, 2011, at 11:46 AM, Mauricio Salatino wrote:
What about the env?
can you show how you set up the environment?
Cheers.
2011/5/26 Shannon Hastings
<shannon.hastings@inventrio.com>
Ya,
session = JPAKnowledgeService.loadStatefulKnowledgeSession(
map.getSessionId(), getKnowledgeBase(), null, env);
On May 26, 2011, at 11:40 AM, Mauricio Salatino wrote:
Are you using the JPAKnowledgeService?
2011/5/26 Shannon Hastings
<shannon.hastings@inventrio.com>
It is actually null. I dont pass any config in when constructing the session.
On May 26, 2011, at 11:13 AM, Mauricio Salatino wrote:
Can you share the ksession configuration?
2011/5/26 Shannon Hastings
<shannon.hastings@inventrio.com>
My session is persistent, i can query the sessioninfo in the DB and see the data. My beans are searializable and I can see that the fact has been deserialized.
On May 26, 2011, at 11:05 AM, Mauricio Salatino wrote:
Ok, assuming that your session is persistent, are your POJOs serializables?
Cheers
2011/5/26 Shannon Hastings
<shannon.hastings@inventrio.com>
Nope, no change, i am pulling the same drl from guvnor every time. It only has three rules as show below in the thread. I can restore the session without error so long as the session does not have any facts in it. Once I drop a fact in and store, then i cannot restore.
On May 26, 2011, at 10:55 AM, Mauricio Salatino wrote:
Ok, so did you check that you didn't change anything from the moment you store the ksession and the moment when you restore it?
I usually find this problem when you change a rule and try to restore the session using the new version of the rule or when you change a business process definition or the session state from different threads. Can you check that please?
You will find this unmarshalling problems and it will be very difficult to debug at that level, when the problem is being caused by some modification on your code. Greetings
2011/5/26 Shannon Hastings
<shannon.hastings@inventrio.com>
I have debugged into this and found this issue. The NPE comes when the session unmarsheller runs into a node that does not have a sink or the sink is null. In the debugger i can see the fact and the fact looks right, has all the data from the pojo i sent in. However, it does not have a sink, but it does have a node id. This looks like a bug that was reportedly fixed before in 5.1. I dont know enough about the storing of the facts in the working memory or the model that is being used under the hood, however, all i have to do to create the problem is create a session, send an object to it, and then try to restore it. And the objects i am sending to it are simple pojo's and in the debugger I can see that it was able to read them back out just fine. Below is an exerpt from the "InputMarshaller" class. In the debugger The readlefttuples operation shows the nodeId = 12 and the sink = null and the facthandleId = 1. he it calls readLeftTuple() and the obvious NPE will be thrown because the ParentLeftTuple has a null sink and when you call "sink.getType()" you get the NPE. Is this a known bug.
public static void readLeftTuples(MarshallerReaderContext context) throws IOException,
ClassNotFoundException {
ObjectInputStream stream = context.stream;
while ( stream.readShort() == PersisterEnums.LEFT_TUPLE ) {
int nodeId = stream.readInt();
LeftTupleSink sink = (LeftTupleSink) context.sinks.get( nodeId );
int factHandleId = stream.readInt();
LeftTuple leftTuple = new LeftTuple( context.handles.get( factHandleId ),
sink,
true );
readLeftTuple( leftTuple,
context );
}
}
public static void readLeftTuple(LeftTuple parentLeftTuple,
MarshallerReaderContext context) throws IOException,
ClassNotFoundException {
ObjectInputStream stream = context.stream;
Map<Integer, BaseNode> sinks = context.sinks;
LeftTupleSink sink = parentLeftTuple.getLeftTupleSink();
switch ( sink.getType() ) {
On May 24, 2011, at 9:06 AM, Edson Tirelli wrote:
Shannon,
What is the following method doing?
engine.process(reading);
Can you please open a JIRA and attach your test case or point me to the jira reporting this problem if it exists already?
Thanks,
Edson
2011/5/23 Shannon Hastings
<shannon.hastings@inventrio.com>
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
$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
$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
$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();
}
}
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @
www.jboss.com
_______________________________________________
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
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
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
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
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
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
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
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
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
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users