repository in 5.2.M2 crashes in 5.2.Final because of decision table serialization
by Vincent LEGENDRE
Hi all
We tried to use the 5.2.Final version of Guvnor, but the compilation fails with an error saying that class "dtable" does not exists.
After looking more depply, it appears that the XML storage format has changed in 5.2.Final :
- root XML is now " decision-table52 " instead of "dtable"
- pattern is now " org.drools.guvnor.client.modeldriven.dt52.Pattern52 " with some condition-column grouped by fact, instead of independant condition-column
- pattern is now " org.drools.guvnor.client.modeldriven.dt52.Pattern52 " with some condition-column grouped by fact, instead of independant condition-column
- actions is now " insert-fact-column 52" instead of the same thing without version in it, but this time no structure changes ...
Is there a way to migrate old tables to new format ?
Changing a repository.xml by subtitutions is OK ?
Do we have to plan such problems for future versions ?
15 years
How to Access and Execute Rules from Database
by Ashish Soni
Hi All ,
I am able to configure oracle database in drools but now i am not able to
find how can i load rules from the DB and execute them , I gone through the
documentation but not able to get much information or might be i am missing
something.
If any one can provide me a example or some pointer ,hints then it would be
helpful.
Regards,
Ashish
15 years
Drools and serialize
by clement.pernot
Hi,
I want to serialize a StatefulKnowledgeSession in drools (which have rule
and fact)
Actually i know how to serialize a KnowledgeBase.
Here is my code for serialize a KnowledgeBase:
KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add( ResourceFactory.newFileResource( "Sample.drl" ),
ResourceType.DRL );
if( kBuilder.hasErrors() ){
for( KnowledgeBuilderError err: kBuilder.getErrors() ){
System.err.println( err.toString() );
}
throw new IllegalStateException( "DRL errors" );
}
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
OutputStream os = new FileOutputStream( "droolsCompiledFile" );
ObjectOutputStream oos = new ObjectOutputStream( os );
oos.writeObject( kBase );
oos.close();
This work fine, no problem here.
Here is my code for serialize a StatefulKnowledgeSession:
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add( ResourceFactory.newFileResource( "Sample.drl" ),
ResourceType.DRL );
if( kBuilder.hasErrors() ){
for( KnowledgeBuilderError err: kBuilder.getErrors() ){
System.err.println( err.toString() );
}
throw new IllegalStateException( "DRL errors" );
}
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
try {
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);
Marshaller marshaller = MarshallerFactory.newMarshaller(
ksession.getKnowledgeBase(), new ObjectMarshallingStrategy[]{
MarshallerFactory.newSerializeMarshallingStrategy() } );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectMarshallingStrategy oms =
MarshallerFactory.newIdentityMarshallingStrategy();
marshaller.marshall( baos, ksession );
ObjectOutputStream out = new ObjectOutputStream( baos );
out.writeObject( marshaller );
out.close();
baos.close();
ksession.fireAllRules();
} catch (Throwable t) {
t.printStackTrace();
}
}
But this didn't work.
I get always the same error:
"java.io.NotSerializableException"
I have try to not implement the "marshall" but this didn't work.
I don't know what I must do. Can someone help me?
Thank.
Best regards,
Clement Pernot
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-and-serialize-tp3161882p3161882....
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
BRMS on WebLogic
by Benson Fung
Hi,
Is there installation documentation how BRMS/Drools Guvnor is
installed on WebLogic server? Please help.
Thanks
Benson
15 years
Temporal reasoning with external persistence not working
by Aman Teja
I am trying to use an external storage for loading and persisting objects.
But when I try a set a temporal reasoning rule it start to fail. The rule,
test code and exception are given below. Please help
// rules file
package foo.externalwm;
global foo.ExternalStorage session;
import foo.externalwm.YUser
import foo.externalwm.Test
declare User
@role(event)
end
declare Contest
@role(event)
end
rule "test"
dialect "java"
when
$c1:Contest() from session.getContestByName("Contest1")
User(this after[0,3m] $c1) from session.getUserByIndex(0)
then
System.out.println("rule fired");
end
// ************ code
public class Test {
public static void main(String[] args) throws Exception {
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption( EventProcessingOption.STREAM );
KnowledgeBase k = init(); // read and compile rules done here
final StatefulKnowledgeSession ksession =
k.newStatefulKnowledgeSession();
ExternalStorage session = new ExternalStorage();
ksession.setGlobal("session", session);
ksession.fireAllRules();
}
***********EXCEPTION
Exception in thread "main" org.drools.RuntimeDroolsException: Unexpected
exception executing action
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction@669a4cb
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:996)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:730)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at foo.externalwm.Test.main(Test.java:55)
Caused by: java.lang.ClassCastException: org.drools.common.DefaultFactHandle
cannot be cast to org.drools.common.EventFactHandle
at
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:332)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:111)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:127)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:137)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:137)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:141)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143)
at org.drools.reteoo.Rete.assertObject(Rete.java:107)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:260)
at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:343)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:994)
... 4 more
--
View this message in context: http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persis...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
accumulate Functions with self coded classes as result type
by Andre
i implemented an accumulate function which uses Datatypes, which i coded my
self , see example
the function return a list of ResourceMatch Objects, but when i try access
that objects i get an NullPointerrException (nothing more) (yes i imported
that class in the DRL)
so it seems that there has to be some kind of registration, so drools, can
handle these objectsm right ?
or what did i forget?
rule "Request counting analysed Resources By Id"
when
$list: List()
from accumulate($neu : RequestCtx() over
window:time(1m),countMatchingAnalysedResourcesInRequest($neu) )
ResourceMatch( $id: uri.toString(), count > 1 ) from $list
then
System.out.println( "Id " + $id + ": " );
System.out.println("Request counting Resources By Id Rule Workss");
channels["AuthZBlocking"].send(new ItemCacheEntry(new Item((String)$id),
new Date(System.currentTimeMillis()+ 8000)));
end
--
View this message in context: http://drools.46999.n3.nabble.com/accumulate-Functions-with-self-coded-cl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
15 years
Any suggestions to implement exclusions and avoid update
by Wishing Carebear
Hi,
Below are 2 rules, rule1 has higher precedence than rule2. Rule2 should not
execute if Rule 1 executes.
1) One way to get this working is to check the null value.
2) If the update is not called, the Rule2 gets executed using the previous
null value of potentialTheftRating.
Is there any other way to implement this requirement.
rule "Rule 1 PotentialTheft0"
ruleflow-group "TheftRating0"
salience 10
no-loop
lock-on-active
when
$client : Client()
$policy : Service(productType == "Vehicle Insurance") from
$client.service
$car : Vehicle(potentialTheftRating == null, vehicleType ==
vehicleTypeType.CAR, convertible == Boolean.TRUE) from $policy.vehicle
then
modify ($car) {
setPotentialTheftRating( potentialTheftRatingType.HIGH )
}
update($client);
end
rule "Rule2 PotentialTheft0"
ruleflow-group "TheftRating0"
no-loop
lock-on-active
when
$client : Client()
$policy : Service(productType == "Vehicle Insurance") from
$client.service
$car : Vehicle(potentialTheftRating == null,vehicleType ==
vehicleTypeType.CAR, price >= 20000, price <= 45000, highTheftProbabilty ==
Boolean.FALSE ) from $policy.vehicle
then
modify ($car) {
setPotentialTheftRating( potentialTheftRatingType.MODERATE )
}
update($client);
end
15 years