[rules-users] Apache XML beans as facts with shadow proxy turned on (Drools 4.0.7)
Hello! I've got a problem with using XML beans (v. 2.2) as facts with shadow proxy turned on (Drools 4.0.7). I'm using a stateful session created by method newStatefulSession(java.io.InputStream stream). I have a base WorkingMemory instance with some predefined facts implemented as Apache XML beans. Then, I write it to an array of bytes using ByteArrayOutputStream and ObjectOutputStream in order to create ByteArrayInputStream and create new stateful session using the method mentioned above. Here is the fragment of my code: // -- BEGIN OF CODE FRAGMENT // This is just an initialization of an XML bean fact MyBean fact1 = MyBean.Factory.newInstance(); fact1.setField1(someText); fact1.setField2(FieldType.Factory.newInstance()); // props contains some properties defined, but it doesn't matter RuleAgent ruleAgent = RuleAgent.newRuleAgent(props); RuleBase ruleBase = ruleAgent.getRuleBase(); // Here I create a base working memory instance WorkingMemory baseWm = ruleBase.newStatefulSession(false); // and insert the fact baseWm.insert(fact1); // Here I write a base working memory to a byte buffer ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); ObjectOutputStream oos1 = new ObjectOutputStream(baos1); oos1.writeObject(baseWm); oos1.close(); byte[] buf1 = baos1.toByteArray(); // and create a new stateful session based on the buffer ByteArrayInputStream bais1 = new ByteArrayInputStream(buf1); StatefulSession session1 = ruleBase.newStatefulSession(bais1); // -- END OF CODE FRAGMENT When shadow proxies is turned off, everything works fine. I can fire rules and they see the fact. But when I turn the shadow proxies on, I've got an exception: java.io.NotSerializableException: org.example.myBean.MyBeanShadowProxy at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302) at java.util.HashMap.writeObject(HashMap.java:2336) 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:585) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347) at
Re: [rules-users] No ClassLoaders found for: String
Thanks, will fix that. https://jira.jboss.org/jira/browse/JBRULES-1918 []s Edson 2009/1/15 Faron Dutton fgdut...@gmail.com I switched to v2.0.6 from v2.0.5 and found a breaking API change. org.mvel2.compiler.ExpressionCompiler no longer has a method called setDebugSymbols. ExpressionCompiler now queries ParserContext for this setting. This affects org.drools.base.mvel.MVELCompilationUnit (line 346) from drools-core and org.drools.rule.builder.dialect.mvel.MVELDialect (line 519) from drools-compiler. *From:* rules-users-boun...@lists.jboss.org [mailto: rules-users-boun...@lists.jboss.org] *On Behalf Of *Edson Tirelli *Sent:* Tuesday, January 13, 2009 11:52 AM *To:* Rules Users List *Subject:* Re: [rules-users] No ClassLoaders found for: String Thanks, next release will use mvel 2.0.6. []s Edson 2009/1/13 Paul Sentosa psent...@yahoo.com Yes, it works with 2.0.6. Otherwise I should define the String separately (String abc = a string; list.add(abc); in order for the consequence to be executed correctly) Thanks Edson! Regards Paul -- *From:* Edson Tirelli tire...@post.com *To:* Rules Users List rules-users@lists.jboss.org *Sent:* Tuesday, January 13, 2009 5:03:32 PM *Subject:* Re: [rules-users] No ClassLoaders found for: String Yes, I see. Can you please manually update your local mvel jar to version 2.0.6 (latest) and try again? I am talking to the MVEL author to make sure the problem is fixed in the latest version, but of course, if you can confirm this on your side, it would be best. []s Edson 2009/1/13 psentosa psent...@yahoo.com I'm using maven to manage my libraries, thus I add these line in my pom.xml: dependency groupIdorg.drools/groupId artifactIddrools-api/artifactId version5.0.0.M4/version /dependency dependency groupIdorg.drools/groupId artifactIddrools-core/artifactId version5.0.0.M4/version /dependency And I can see that mvel2-2.0.4 has been added, besides drools-api and core 5.0.0.M4 Thanks for the reply Edson Tirelli-3 wrote: What MVEL version are you using? []s Edson 2009/1/13 psentosa psent...@yahoo.com Hallo, I have a rule like this, defined in Guvnor: when Activity ( $date : date, workingTime 240) then System.out.println(Working time limit has been reached); violatedRegulation.add(new String(regulation.general.working1)); violatedRegulation is a ListString which I set as a global because later on I will extract the content of that list which is a key defined in a properties file ksession.setGlobal(violatedRegulation, violatedRegulation); ksession.executeObject(activity); but then I got the following exception: 15:52:59,687 INFO [STDOUT] Working time limit has been reached 15:52:59,687 ERROR [MyExceptionInterceptor] [Error: could not create constructor: No ClassLoaders found for: String ] [Near : {... Unknown }] ^ org.drools.runtime.rule.ConsequenceException: [Error: could not create constructor: No ClassLoaders found for: String ] [Near : {... Unknown }] ^ at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:918) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:871) at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1035) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:612) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:589) at org.drools.impl.StatelessKnowledgeSessionImpl.executeObject(StatelessKnowledgeSessionImpl.java:158) .. Caused by: [Error: could not create constructor: No ClassLoaders found for: String ] [Near : {... Unknown }] ^ at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeObjectCreation(ReflectiveAccessorOptimizer.java:805) at org.mvel2.optimizers.dynamic.DynamicOptimizer.optimizeObjectCreation(DynamicOptimizer.java:80) at org.mvel2.ast.NewObjectNode.getReducedValueAccelerated(NewObjectNode.java:148) at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:37) at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:590) at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:285) at
RE: [rules-users] NPE in RightTuple
Possibly, upon inspection I found an entity class with suspicious looking hashCode and equals methods (source generate equals/hashcode is still to hard for some people it seems). I'm trying to recreate a simple test case, to reproduce. What's the simplest rule to generate a RightTupleIndexHashTable? Will any attribute constraint do e.g.: BadClass($value : value) BadClass(value == $value) Thanks, -Jess From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: Wednesday, January 14, 2009 4:43 PM To: Rules Users List Subject: Re: [rules-users] NPE in RightTuple Looks like a bug. Can you please open a JIRA with a test case? My guess is that your rules are changing a fact attribute that is causing the equals()/hashcode() methods of the object to return a different result? []s Edson 2009/1/14 Evans, Jess jev...@collegeboard.org Does anyone know what this would be indicative of? I've seen it occur periodically at which point I have to discard the session. I flatten and assert my data, run the rules, and then retract the handles collected on assertion. I've ensured the fact handle parameter is never null. I have the stateful session wrapped in a synchronized business façade, so I don't think it should be a concurrency issue (unless I have a bug of course). I'm running Drools 5 M4. java.lang.NullPointerException at org.drools.util.RightTupleIndexHashTable.remove(RightTupleIndexHashTable.java:224) at org.drools.reteoo.JoinNode.retractRightTuple(JoinNode.java:204) at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:210) at org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:190) at org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1078) at org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1045) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] NPE in RightTuple
Evans, Jess wrote: Possibly, upon inspection I found an entity class with suspicious looking hashCode and equals methods (source generate equals/hashcode is still to hard for some people it seems). I'm trying to recreate a simple test case, to reproduce. What's the simplest rule to generate a RightTupleIndexHashTable? Will any attribute constraint do e.g.: BadClass($value : value) BadClass(value == $value) any == constraint against a declaration (pattern bound to a variable) will produce an indexed join. Thanks, -Jess *From:* rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] *On Behalf Of *Edson Tirelli *Sent:* Wednesday, January 14, 2009 4:43 PM *To:* Rules Users List *Subject:* Re: [rules-users] NPE in RightTuple Looks like a bug. Can you please open a JIRA with a test case? My guess is that your rules are changing a fact attribute that is causing the equals()/hashcode() methods of the object to return a different result? []s Edson 2009/1/14 Evans, Jess jev...@collegeboard.org mailto:jev...@collegeboard.org Does anyone know what this would be indicative of? I've seen it occur periodically at which point I have to discard the session. I flatten and assert my data, run the rules, and then retract the handles collected on assertion. I've ensured the fact handle parameter is never null. I have the stateful session wrapped in a synchronized business façade, so I don't think it should be a concurrency issue (unless I have a bug of course). I'm running Drools 5 M4. java.lang.NullPointerException at org.drools.util.RightTupleIndexHashTable.remove(RightTupleIndexHashTable.java:224) at org.drools.reteoo.JoinNode.retractRightTuple(JoinNode.java:204) at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:210) at org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:190) at org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1078) at org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1045) ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com http://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
Re: [rules-users] Decision Tree input?
Mark Proctor wrote: Wilson O Ojwang wrote: All, Is there something in the works to support Decision Tree Inputs in addition to Decision Table? Someone in the community is working on this in eclipse, but they start and stop work on it, nothing is commited yet so no idea if they will deliver or when. Where could one find more information on the work being done on the Decision trees? I would like to know more about the project, its status and the possibillity to help out!? any pointers would be appreciated. /W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Firing Rules in Rule Flows
I have a fairly involved rule flow consisting of rule flow groups. I am trying to understand if the behavior I am seeing and my understanding of it are correct. The flow executes as exepected the first pass through, objects are inserted and the rules associated with the different nodes are executed. On the second pass through the flow various nodes are triggered but none of the ruleflow groups are activated/executed. My understanding of this is as follows: 1) The only way to have these ruleflow groups fire/execute again is to insert objects that cause a match or to fire all rules on the session again. 2) Constraints on split/join nodes are always evaluated and don't need to be activated which is different than the constraints on a given rule 3) Rules that don't have any constraints, i.e. they are always true will only execute once and will only execute with a call to fire all rules Assuming my understanding of what is going on correct I have the following questions: Q. My particular use case is really screen flow/business process, and it would be nice if I came to a node, that the rule was always evaluated, i.e. currently rules that always evaluate to true aren't fired more than once. For instance I have a node that simply instantiates a dialog and waits for user input and I always want to instantiate that dialog when I come to that node, regardless of the facts. Is there a way to achieve this without firing all rules again? Q. Is firing all rules within a rule flow a legitimate way of achieving the desired affect? Shouldn't the ruleflow-group associated with a node always be evaluated if the node is triggered? As it happens now, the rule flow gets stuck in an infinite loop as the node contraints are conitniously evaluated but the actual rule contraints are not. Seems inconsistent too me especially in the context of a business process/rule flow. Thanks -- View this message in context: http://www.nabble.com/Firing-Rules-in-Rule-Flows-tp21489239p21489239.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Firing Rules in Rule Flows
AFAIK, your understanding is correct. What fireAllRules does is it executes rules on agenda(contains rules with all conditions matched) until the agenda is empty. A rule can get to agenda when you modify a fact or insert/retract a fact. If you call fireAllRules on an empty agenda no rule will be fired. The ruleflow groups just make the rules execute in specific order. On Thu, Jan 15, 2009 at 11:22 PM, keithnielsen keithniel...@discover.comwrote: I have a fairly involved rule flow consisting of rule flow groups. I am trying to understand if the behavior I am seeing and my understanding of it are correct. The flow executes as exepected the first pass through, objects are inserted and the rules associated with the different nodes are executed. On the second pass through the flow various nodes are triggered but none of the ruleflow groups are activated/executed. My understanding of this is as follows: 1) The only way to have these ruleflow groups fire/execute again is to insert objects that cause a match or to fire all rules on the session again. 2) Constraints on split/join nodes are always evaluated and don't need to be activated which is different than the constraints on a given rule 3) Rules that don't have any constraints, i.e. they are always true will only execute once and will only execute with a call to fire all rules Assuming my understanding of what is going on correct I have the following questions: Q. My particular use case is really screen flow/business process, and it would be nice if I came to a node, that the rule was always evaluated, i.e. currently rules that always evaluate to true aren't fired more than once. For instance I have a node that simply instantiates a dialog and waits for user input and I always want to instantiate that dialog when I come to that node, regardless of the facts. Is there a way to achieve this without firing all rules again? Q. Is firing all rules within a rule flow a legitimate way of achieving the desired affect? Shouldn't the ruleflow-group associated with a node always be evaluated if the node is triggered? As it happens now, the rule flow gets stuck in an infinite loop as the node contraints are conitniously evaluated but the actual rule contraints are not. Seems inconsistent too me especially in the context of a business process/rule flow. Thanks -- View this message in context: http://www.nabble.com/Firing-Rules-in-Rule-Flows-tp21489239p21489239.html Sent from the drools - user mailing list archive at Nabble.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
[rules-users] meet Operator 'Operator = 'contains'' does not exist for StringEvaluator error
Hi, all: I meet a strange error when use contains operator on string type, My rule is like below: package org.drools.examples; import org.drools.examples.HelloWorldExample.Message; rule check str contains dialect java when m:Message( message contains Hello ) then System.out.println( ===check str contains ok=== ); end It throw below exception: Exception in thread main java.lang.RuntimeException: Operator 'Operator = 'contains'' does not exist for StringEvaluator at org.drools.base.evaluators.StringFactory.getEvaluator(StringFactory.java:70) at org.drools.base.ValueType.getEvaluator(ValueType.java:166) at org.drools.rule.builder.PatternBuilder.getEvaluator(PatternBuilder.java:900) at org.drools.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:714) at org.drools.rule.builder.PatternBuilder.buildRestriction(PatternBuilder.java:625) at org.drools.rule.builder.PatternBuilder.createRestriction(PatternBuilder.java:434) at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:308) at org.drools.rule.builder.PatternBuilder.buildConstraint(PatternBuilder.java:199) at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:168) at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:93) at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69) at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:53) at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167) at org.drools.examples.HelloWorldExample.main(HelloWorldExample.java:28) But if I use a deep str field, this issue does not exist, Everything goes well. The drl is like below: package org.drools.examples; import org.drools.examples.HelloWorldExample.Message; rule check deep str contains dialect java when m:Message( sec.fir.msg contains Hello ) then System.out.println( ===check deep str contains ok=== ); end It seems a bug, but I am not sure. I attached my test code and the two drl files. I use below jars to compile and run this test case: antlr-runtime-3.0.jar core-3.2.3.v_686_R32x.jar drools-compiler-4.0.7.jar drools-core-4.0.7.jar drools-decisiontables-4.0.7.jar drools-jsr94-4.0.7.jar janino-2.5.10.jar jsr94-1.1.jar mvel-1.3.12-java1.4.2.jar Can everyone kindly give me any suggestion? Thanks! - Zeke DeepStr.drl Description: Binary data Str.drl Description: Binary data HelloWorldExample.java Description: Binary data ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users