Two drools that validate the same instance in one Guvnor package
by Serge Vilvovsky
I am a beginner with drools, sorry, if the question is too trivial.
I have two drl files A and B. Both they validate the instance of the same
type T, but produce the different output.
I call the drool A within one business flow and drool B within another flow.
Before now I ran them locally, creating two separate KnowledgeBases, and
everything worked fine. Now I want to use the Guvnor.
If I put them to the same package and run:
http://<server>/guvnor-webapp/org.drools.guvnor.Guvnor/package/<packageName>/LATEST
I will get the KnowledgeBase that contains them both, I believe. According
to my understanding, because they process the instance of the same type, I
cannot use such KnowledgeBase.
What should I do? Is it any API that allows to distinguish the
KnowelageBases for the different drools within the same package or I need to
put them to the different packages?
Thank you!
13 years, 5 months
Now that @author is gone...
by Wolfgang Laun
...there are still some relics around: old CVS tags. For instance, in
org/drools/conflict/FifoConflictResolver.java we find:
* @version $Id: RandomConflictResolver.java,v 1.1 2004/06/25 01:55:16
mproctor
* Exp $
For the drools repository:
drools[FIX-INF]$ grep -l '@version' $j
./drools-compiler/src/test/java/org/drools/IndexedNumber.java
./drools-core/src/test/java/org/drools/factmodel/InstancesHashcodedTest.java
./drools-core/src/test/java/org/drools/spi/MockObjectType.java
./drools-core/src/main/java/org/drools/RuleIntegrationException.java
./drools-core/src/main/java/org/drools/base/ClassObjectType.java
./drools-core/src/main/java/org/drools/spi/ConflictResolver.java
./drools-core/src/main/java/org/drools/spi/Accumulator.java
./drools-core/src/main/java/org/drools/spi/RuleComponent.java
./drools-core/src/main/java/org/drools/ProcessIntegrationException.java
./drools-core/src/main/java/org/drools/rule/Package.java
./drools-core/src/main/java/org/drools/rule/FixedDuration.java
./drools-core/src/main/java/org/drools/core/util/StringUtils.java
./drools-core/src/main/java/org/drools/core/util/CompositeCollection.java
./drools-core/src/main/java/org/drools/core/util/IteratorChain.java
./drools-core/src/main/java/org/drools/core/util/ArrayUtils.java
./drools-core/src/main/java/org/drools/core/util/ArrayIterator.java
./drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
./drools-core/src/main/java/org/drools/common/InstanceEqualsConstraint.java
./drools-core/src/main/java/org/drools/conflict/AbstractConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/TotalRecencyConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/FifoConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/ComplexityConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/SimplicityConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/SalienceConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/LifoConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/RandomConflictResolver.java
./drools-core/src/main/java/org/drools/conflict/LoadOrderConflictResolver.java
./drools-core/src/main/java/org/drools/util/codec/StringUtils.java
./drools-core/src/main/java/org/drools/util/codec/Base64.java
./drools-core/src/main/java/org/drools/util/codec/CharEncoding.java
./drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
./drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
./drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoaderTest.java
./drools-jsr94/src/test/java/org/drools/jsr94/rules/repository/TestRuleExecutionSetRepository.java
./drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryLoader.java
./drools-jsr94/src/main/java/org/drools/jsr94/rules/repository/RuleExecutionSetRepositoryException.java
13 years, 5 months
FW: Drools in non-eclipse environment
by Abhay B. Chaware
I am have now managed to get past all the compiler errors for Drools on android .. ( I think ) :) .
My app is failing ( crashing ) when run on android device. Looking at the log, appears to be a heap memory problem, can anyone see anything suspicious here in the android log, that may point to the drools code as suspect ?
I/DEBUG ( 1280): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 1280): Build fingerprint: 'samsung/GT-I9003/GT-I9003/GT-I9003:2.2.1/FROYO/XXKB3:user/release-keys'
I/DEBUG ( 1280): pid: 11341, tid: 11341 >>> com.first <<<
I/DEBUG ( 1280): signal 11 (SIGSEGV), fault addr 0000004c
I/DEBUG ( 1280): r0 00000000 r1 4831de40 r2 00000000 r3 00000000
I/DEBUG ( 1280): r4 809a2400 r5 00240d00 r6 00000000 r7 0000cd28
I/DEBUG ( 1280): r8 80917040 r9 0000cd28 10 430cb970 fp bea15728
I/DEBUG ( 1280): ip 00000000 sp bea153a8 lr 809681f7 pc 8096809c cpsr 80000070
I/DEBUG ( 1280): d0 65643a64696f7262 d1 0065006400610075
I/DEBUG ( 1280): d2 4ba11af200000567 d3 000000004b815b67
I/DEBUG ( 1280): d4 0065007400730079 d5 00610050002e006d
I/DEBUG ( 1280): d6 006c004300680074 d7 3eaaaaab3f800000
I/DEBUG ( 1280): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 1280): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 1280): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 1280): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 1280): d16 ade4622100000000 d17 0064002f005b0072
I/DEBUG ( 1280): d18 002f006100740061 d19 002f007000700061
I/DEBUG ( 1280): d20 0073002e006b0069 d21 0065007400730079
I/DEBUG ( 1280): d22 00610050002e006d d23 006c004300680074
I/DEBUG ( 1280): d24 3ff0000000000000 d25 0000000000000000
I/DEBUG ( 1280): d26 0000000000000000 d27 0000000000000000
I/DEBUG ( 1280): d28 0000000000000000 d29 0000000000000000
I/DEBUG ( 1280): d30 0000000000000000 d31 0000000000000000
I/DEBUG ( 1280): scr 80000012
I/DEBUG ( 1280):
I/DEBUG ( 1280): #00 pc 0006809c /system/lib/libdvm.so
I/DEBUG ( 1280): #01 pc 000681f2 /system/lib/libdvm.so
I/DEBUG ( 1280): #02 pc 00068238 /system/lib/libdvm.so
I/DEBUG ( 1280): #03 pc 000690a6 /system/lib/libdvm.so
I/DEBUG ( 1280): #04 pc 00061a0c /system/lib/libdvm.so
I/DEBUG ( 1280): #05 pc 00063f1a /system/lib/libdvm.so
I/DEBUG ( 1280): #06 pc 0001bdd8 /system/lib/libdvm.so
I/DEBUG ( 1280): #07 pc 000227d4 /system/lib/libdvm.so
I/DEBUG ( 1280): #08 pc 00021674 /system/lib/libdvm.so
I/DEBUG ( 1280): #09 pc 0005c7d6 /system/lib/libdvm.so
I/DEBUG ( 1280): #10 pc 00064ef8 /system/lib/libdvm.so
I/DEBUG ( 1280): #11 pc 0001bdd8 /system/lib/libdvm.so
I/DEBUG ( 1280): #12 pc 000227d4 /system/lib/libdvm.so
I/DEBUG ( 1280): #13 pc 00021674 /system/lib/libdvm.so
I/DEBUG ( 1280): #14 pc 0005c614 /system/lib/libdvm.so
I/DEBUG ( 1280): #15 pc 00047cd6 /system/lib/libdvm.so
I/DEBUG ( 1280): #16 pc 000364b4 /system/lib/libandroid_runtime.so
I/DEBUG ( 1280): #17 pc 0003808c /system/lib/libandroid_runtime.so
I/DEBUG ( 1280): #18 pc 00008ca8 /system/bin/app_process
I/DEBUG ( 1280): #19 pc 0000d404 /system/lib/libc.so
I/DEBUG ( 1280):
I/DEBUG ( 1280): code around pc:
I/DEBUG ( 1280): 8096807c 0f02f1be 2500bfd8 b0054628 bf00bdf0
I/DEBUG ( 1280): 8096808c 0003a3c8 000003a0 fffc3f91 41f0e92d
I/DEBUG ( 1280): 8096809c 4d216cc3 4606a200 18ad460f d0384299
I/DEBUG ( 1280): 809680ac e078f8df 400ef855 208cf8d4 0014f112
I/DEBUG ( 1280): 809680bc eb0cf7ae c094f8d4 f1bc6a73 bf180100
I/DEBUG ( 1280):
I/DEBUG ( 1280): code around lr:
I/DEBUG ( 1280): 809681d4 461a9905 633e1820 fb12f7d9 46089902
I/DEBUG ( 1280): 809681e4 f7e84639 e004faa7 99044610 f7ff4616
I/DEBUG ( 1280): 809681f4 9803ff51 f7e82100 4628fa9d ed6af7ae
I/DEBUG ( 1280): 80968204 b0094630 bf00bdf0 0003a2c8 fffe46a4
I/DEBUG ( 1280): 80968214 ffff026e ffff1926 fffe2288 ffff194c
I/DEBUG ( 1280):
I/DEBUG ( 1280): stack:
I/DEBUG ( 1280): bea15368 430faf80 /dev/ashmem/dalvik-LinearAlloc (deleted)
I/DEBUG ( 1280): bea1536c 0000cd28 [heap]
I/DEBUG ( 1280): bea15370 bea153c4 [stack]
I/DEBUG ( 1280): bea15374 8095c61d /system/lib/libdvm.so
I/DEBUG ( 1280): bea15378 8099266e /system/lib/libdvm.so
I/DEBUG ( 1280): bea1537c 4831de40 /dev/ashmem/mspace/dalvik-heap/2 (deleted)
I/DEBUG ( 1280): bea15380 439121ed /system/framework/core.odex
I/DEBUG ( 1280): bea15384 00000000
I/DEBUG ( 1280): bea15388 bea15340 [stack]
I/DEBUG ( 1280): bea1538c 0000001f
I/DEBUG ( 1280): bea15390 80993d3a /system/lib/libdvm.so
I/DEBUG ( 1280): bea15394 809a2400 /system/lib/libdvm.so
I/DEBUG ( 1280): bea15398 00240d00 [heap]
I/DEBUG ( 1280): bea1539c 00000000
I/DEBUG ( 1280): bea153a0 df002777
I/DEBUG ( 1280): bea153a4 e3a070ad
I/DEBUG ( 1280): #00 bea153a8 809a2400 /system/lib/libdvm.so
I/DEBUG ( 1280): bea153ac 00240d00 [heap]
I/DEBUG ( 1280): bea153b0 00000000
I/DEBUG ( 1280): bea153b4 0000cd28 [heap]
I/DEBUG ( 1280): bea153b8 80917040 /system/lib/libdvm.so
I/DEBUG ( 1280): bea153bc 809681f7 /system/lib/libdvm.so
I/DEBUG ( 1280): #01 bea153c0 4867acc0 /dev/ashmem/mspace/dalvik-heap/2 (deleted)
I/DEBUG ( 1280): bea153c4 400092d0 /dev/ashmem/mspace/dalvik-heap/zygote/0 (deleted)
I/DEBUG ( 1280): bea153c8 00000000
I/DEBUG ( 1280): bea153cc 4867acc0 /dev/ashmem/mspace/dalvik-heap/2 (deleted)
I/DEBUG ( 1280): bea153d0 4831de40 /dev/ashmem/mspace/dalvik-heap/2 (deleted)
I/DEBUG ( 1280): bea153d4 00240ce8 [heap]
I/DEBUG ( 1280): bea153d8 00000000
I/DEBUG ( 1280): bea153dc ade46221 /system/lib/libicuuc.so
I/DEBUG ( 1280): bea153e0 00000001
I/DEBUG ( 1280): bea153e4 00240ce8 [heap]
I/DEBUG ( 1280): bea153e8 4831de40 /dev/ashmem/mspace/dalvik-heap/2 (deleted)
I/DEBUG ( 1280): bea153ec 809a2400 /system/lib/libdvm.so
I/DEBUG ( 1280): bea153f0 00240cd0 [heap]
I/DEBUG ( 1280): bea153f4 8096823d /system/lib/libdvm.so
-abhay
________________________________
From: Abhay B. Chaware
Sent: Monday, June 13, 2011 9:43 AM
To: 'Rules Users List'
Subject: FW: [rules-users] Drools in non-eclipse environment
Any ideas folks ?
________________________________
From: Abhay B. Chaware
Sent: Friday, June 10, 2011 12:54 PM
To: 'Rules Users List'
Subject: RE: [rules-users] Drools in non-eclipse environment
The ride's real fun :)
Got apache harmony's beans.jar to work .. now , when I am reading the serialized knowledgebase object on android, quite obvious, it is throwing this error -
java.lang.UnsupportedOperationException: can't load this type of class file
since my serialized knowledgebase object is in java format .. and not dex. Can this serialized version be converted into .dex format using the "dx" utility - pre or post serialization ? I tried the "dx" tool on the serialized object, but it doesn't seem to understand the format.
-abhay
________________________________
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Michael Anstis
Sent: Thursday, June 09, 2011 6:37 PM
To: Rules Users List
Subject: Re: [rules-users] Drools in non-eclipse environment
http://meteatamel.wordpress.com/2010/08/25/android-api-and-java-beans-pac...
http://meteatamel.wordpress.com/2010/09/28/android-api-and-java-beans-pac...
Enjoy the ride ;)
2011/6/9 Abhay B. Chaware <Abhay.Chaware(a)kpitcummins.com<mailto:Abhay.Chaware@kpitcummins.com>>
woo hooo ! I got past that problem :) But a new one's here now.
Looks like MVEL is not liking something :)
W/dalvikvm(29977): VFY: unable to resolve static method 164: Ljava/beans/Introspector;.decapitalize (Ljava/lang/String;)Ljava/lang
/String;
W/dalvikvm(29977): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
E/AndroidRuntime(29977): FATAL EXCEPTION: main
E/AndroidRuntime(29977): java.lang.NoClassDefFoundError: java.beans.Introspector
E/AndroidRuntime(29977): at org.drools.core.util.asm.ClassFieldInspector.calcFieldName(ClassFieldInspector.java:298)
E/AndroidRuntime(29977): at org.drools.core.util.asm.ClassFieldInspector.addToMapping(ClassFieldInspector.java:216)
E/AndroidRuntime(29977): at org.drools.core.util.asm.ClassFieldInspector.processClassWithoutByteCode(ClassFieldInspector.ja
va:148)
E/AndroidRuntime(29977): at org.drools.core.util.asm.ClassFieldInspector.<init>(ClassFieldInspector.java:83)
E/AndroidRuntime(29977): at org.drools.core.util.asm.ClassFieldInspector.<init>(ClassFieldInspector.java:64)
E/AndroidRuntime(29977): at org.drools.base.ClassFieldAccessorFactory.getClassFieldReader(ClassFieldAccessorFactory.java:11
8)
E/AndroidRuntime(29977): at org.drools.base.ClassFieldAccessorCache$CacheEntry.getReadAccessor(ClassFieldAccessorCache.java
:168)
E/AndroidRuntime(29977): at org.drools.base.ClassFieldAccessorCache.getReadAcessor(ClassFieldAccessorCache.java:101)
E/AndroidRuntime(29977): at org.drools.base.ClassFieldAccessorStore.wire(ClassFieldAccessorStore.java:404)
E/AndroidRuntime(29977): at org.drools.base.ClassFieldAccessorStore.wire(ClassFieldAccessorStore.java:374)
E/AndroidRuntime(29977): at org.drools.common.AbstractRuleBase.readExternal(AbstractRuleBase.java:295)
E/AndroidRuntime(29977): at org.drools.reteoo.ReteooRuleBase.readExternal(ReteooRuleBase.java:236)
E/AndroidRuntime(29977): at org.drools.impl.KnowledgeBaseImpl.readExternal(KnowledgeBaseImpl.java:108)
E/AndroidRuntime(29977): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2127)
E/AndroidRuntime(29977): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:929)
E/AndroidRuntime(29977): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2285)
E/AndroidRuntime(29977): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2240)
E/AndroidRuntime(29977): at com.ts.DBconnector.execPackageByPath(DBconnector.java:219)
E/AndroidRuntime(29977): at com.first.FirstActivity.onCreate(FirstActivity.java:77)
E/AndroidRuntime(29977): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(29977): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime(29977): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(29977): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(29977): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(29977): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29977): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(29977): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(29977): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(29977): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(29977): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(29977): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(29977): at dalvik.system.NativeStart.main(Native Method)
________________________________
From: rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org> [mailto:rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>] On Behalf Of Michael Anstis
Sent: Thursday, June 09, 2011 4:51 PM
To: Rules Users List
Subject: Re: [rules-users] Drools in non-eclipse environment
Great news :)
Please do feedback... if you get it working I'll make a blog entry on your behalf as you are not the first (or last) to try Drools on Android.
With kind regards,
Mike
2011/6/9 Abhay B. Chaware <Abhay.Chaware(a)kpitcummins.com<mailto:Abhay.Chaware@kpitcummins.com>>
That's exactly what I am trying out at the moment .. option - b. Pre-compile, serialize and unserialize ...I'll share the results.
Also rule file's there at the location mentioned. So that's not a problem.
I've gone through the blog you mentioned ... and as you indicated, it's only jbpm .. no rules ...
thanks
abhay
________________________________
From: rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org> [mailto:rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>] On Behalf Of Michael Anstis
Sent: Thursday, June 09, 2011 4:07 PM
To: Rules Users List
Subject: Re: [rules-users] Drools in non-eclipse environment
Preparing to be shouted down, but isn't it impossible to compile DRL on Android and the suggestion is to load pre-serialised KnowledgeBases?
Also, as another observation, are you sure the DRL was indeed found and the NPE is not caused by "com.ts.DBconnector.readKnowledgeBase(DBconnector.java:143)" perhaps passing a null to KnowledgeBuilder?
Have you looked at http://blog.athico.com/2011/03/jbpm5-lightweight-running-on-android.html, which might give some pointers - although it is only jBPM and not rules themselves.
With kind regards,
Mike
On 9 June 2011 11:11, Abhay B. Chaware <Abhay.Chaware(a)kpitcummins.com<mailto:Abhay.Chaware@kpitcummins.com>> wrote:
This is what I did.
Properties properties = new Properties();
properties.put("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration kbConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration( properties, (ClassLoader[]) null );
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbConfig);
kbuilder.add(ResourceFactory.newInputStreamResource(is), ResourceType.DRL);
I am getting same error with KnowledgeBuilderConfiguration ..
W/System.err(27303): java.lang.NullPointerException
W/System.err(27303): at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:47)
W/System.err(27303): at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1161)
W/System.err(27303): at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:637)
W/System.err(27303): at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:267)
W/System.err(27303): at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:459)
W/System.err(27303): at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
W/System.err(27303): at com.ts.DBconnector.readKnowledgeBase(DBconnector.java:143)
W/System.err(27303): at com.first.FirstActivity.onCreate(FirstActivity.java:64)
W/System.err(27303): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
W/System.err(27303): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
W/System.err(27303): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
W/System.err(27303): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
________________________________________
From: rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org> [rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>] On Behalf Of Wolfgang Laun [wolfgang.laun(a)gmail.com<mailto:wolfgang.laun@gmail.com>]
Sent: Thursday, June 09, 2011 2:46 PM
To: Rules Users List
Subject: Re: [rules-users] Drools in non-eclipse environment
You might try this:
Properties props = new Properties();
props.put( "drools.dialect.java.compiler", "JANINO" );
KnowledgeBuilderConfiguration kbConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration( props, (ClassLoader[]) null );
Requires the janino jar in your classpath, which I have as
~/.m2/repository/janino/janino/2.5.15/janino-2.5.15.jar
-W
On 9 June 2011 10:29, Abhay B. Chaware <Abhay.Chaware(a)kpitcummins.com<mailto:Abhay.Chaware@kpitcummins.com><mailto:Abhay.Chaware@kpitcummins.com<mailto:Abhay.Chaware@kpitcummins.com>>> wrote:
I am using drools 5.1.0
Let me explain what I am trying to do. I am trying to write a drools app on to android platform. In my app, I have added following jars in the application classpath -
antlr-runtime.jar
drools-api.jar
drools-compiler.jar
drools-core.jar
mvel2.jar
Do I need any other jar files ?
upon drilling down into the Null Pointer Exception, it appears that it is throwing NPE at following line inside RuleBuilder.java
RuleConditionBuilder builder = (RuleConditionBuilder)context.getDialect().getBuilder(ruleDescr.getLhs().getClass());
and on further drilling, I found that "context.getDialect()" is retuning NULL.
Then I put some debug inside PackageBuilder.java
upon drilling down for the error, found out that it is not able to set the context's dialect.
ctr.getDialect(pkgRegistry.getDialect()) gives "null" ...
DialectCompiletimeRegistry ctr = pkgRegistry.getDialectCompiletimeRegistry();
RuleBuildContext context = new RuleBuildContext(this, ruleDescr, ctr, pkg, ctr.getDialect(pkgRegistry.getDialect()));
Is there any default setting /configuration that I am obviously missing ?
what could be the problem ?
-abhay
________________________________________
From: rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org><mailto:rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>> [rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org><mailto:rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>>] On Behalf Of Swindells, Thomas [TSwindells(a)nds.com<mailto:TSwindells@nds.com><mailto:TSwindells@nds.com<mailto:TSwindells@nds.com>>]
Sent: Thursday, June 09, 2011 1:40 PM
To: Rules Users List
Subject: Re: [rules-users] Drools in non-eclipse environment
Which version of drools is this?
For drools 5.0.1 we just use maven to resolve the dependencies for us and it works fine. I can't obviously see any eclipse compiler in the jars that we distribute with our application.
Thomas
> -----Original Message-----
> From: rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org><mailto:rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>> [mailto:rules-users-<mailto:rules-users-><mailto:rules-users-<mailto:rules-users->>
> bounces(a)lists.jboss.org<mailto:bounces@lists.jboss.org><mailto:bounces@lists.jboss.org<mailto:bounces@lists.jboss.org>>] On Behalf Of Abhay B. Chaware
> Sent: 09 June 2011 08:06
> To: rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org><mailto:rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>>
> Subject: [rules-users] Drools in non-eclipse environment
>
> Has anyone tried using drools in non-eclipse env ? meaning that
> org.eclipse.jdt.core_3.5.1.v_972_R35x.jar is not in the classpath ?
>
> Documentation says this :
>
> (http://docs.huihoo.com/drools/4.0.7/ch02s05.html)
>
> if you do not have Eclipse JDT Core in your classpath you must override the
> compiler setting before you instantiate this PackageBuilder, you can either
> do that with a packagebuilder properties file the ChainedProperties class will
> find, or you can do it programmatically as shown below; note this time I use
> properties to inject the value for startup.
>
> They also provide an example, but I am not able to figure out exactly how to
> use this example/info.
>
> Here is my code :
>
> KnowledgeBuilder kbuilder =
> KnowledgeBuilderFactory.newKnowledgeBuilder();
> kbuilder.add(ResourceFactory.newInputStreamResource(is),
> ResourceType.DRL);
>
> where "is" is input stream containing the rule file ( .drl)
>
> How do I override the compiler setting ?
>
> I am getting a null pointer exception ( see below ) and I suspect that
> overriding the packagebuilderconfiguration will fix it ?
>
> W/System.err(25511): java.lang.NullPointerException
> W/System.err(25511): at
> org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:47)
> W/System.err(25511): at
> org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1161)
> W/System.err(25511): at
> org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:637)
> W/System.err(25511): at
> org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
> :267)
> W/System.err(25511): at
> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder
> .java:459)
> W/System.err(25511): at
> org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.ja
> va:28)
> W/System.err(25511): at
> com.ts.DBconnector.readKnowledgeBase(DBconnector.java:146)
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org><mailto:rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>>
> https://lists.jboss.org/mailman/listinfo/rules-users
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com<mailto:postmaster@nds.com><mailto:postmaster@nds.com<mailto:postmaster@nds.com>> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org><mailto:rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org><mailto:rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
13 years, 5 months
Re: [rules-users] How does Drools support Notifications?
by Greg Stasica
hi,
I've been evaluating activiti.org recently with a positive result. My
experience with the engine has been quite good so far and the whole
logic behind it seems to much better suite process engine scenarios e.g.
job executors, scheduled events etc. Drools Flow or how they call it
jbpm5 is more rule centric.
regards
On 14/06/2011 14:17, Daniel Nathanson wrote:
> Hi Greg,
>
> This reply is off-list.
>
> What do you mean by
>
> "i've already gave up with drools-flow/jbpm5 due
>> to its problems with persistence causing the whole process to be prone
>> for any kind of inconsistency"?
>
> I'm about to give up on Drools also because I've got flows that randomly stop after being reloaded from the DB. I've been unable to figure out the issue. The Drools code is an undocumented mess and the Drools developers have been unresponsive to problems in Drools Flow.
>
> What did you switch to? I am planning on writing my own state machine.
>
> Regards,
>
> Dan
> Sent from my iPad
>
> On Jun 14, 2011, at 8:15 AM, Greg Stasica<gstasica(a)pacemetrics.com> wrote:
>
>> hi,
>> i'm not sure exactly (as i've already gave up with drools-flow/jbpm5 due
>> to its problems with persistence causing the whole process to be prone
>> for any kind of inconsistency) but i don't think that there is any
>> support for out of the box notification mechanism. I'd rather suspect
>> that one should register some listener and have it called/available as a
>> part of separate running thread
>>
>>
>> On 14/06/2011 08:24, Jay wrote:
>>> ervice.TaskService) and
>>> DefaultEscalatedDeadlineHandler, I can construct the TaskService with a
>>> DefaultEscalatedDeadlineHandler to handle the notification in TaskServer.
>>>
>>> But, will it work? According to
>> --
>> Greg Stasica
>>
>> PaceMetrics Ltd.
>> T +353 1 8849921
>>
>> PaceMetrics Limited is registered in Ireland as a private company limited by shares, Registration No. 298243, Registered office: PaceMetrics House, East Point Business Park, Dublin 3. This e-mail may contain confidential, proprietary or privileged information. If you are not the intended recipient (or have received this e-mail in error) please destroy this e-mail and notify the sender immediately by telephoning +353 1 8184000. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
--
Greg Stasica
PaceMetrics Ltd.
T +353 1 8849921
PaceMetrics Limited is registered in Ireland as a private company limited by shares, Registration No. 298243, Registered office: PaceMetrics House, East Point Business Park, Dublin 3. This e-mail may contain confidential, proprietary or privileged information. If you are not the intended recipient (or have received this e-mail in error) please destroy this e-mail and notify the sender immediately by telephoning +353 1 8184000. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
13 years, 5 months
M1 Vs CR1
by Saleem Lakhani
Hi guys,
Just wanted to know what is the difference b/w Drools 5.2 M1 and Drools
5.2 CR1?
Thanks,
saleem
13 years, 5 months
Can I solve the 'Zebra Puzzle' in drools?
by Miles Wen
hello everybody,
I have some trouble in solving the 'Zebra
Puzzle<http://en.wikipedia.org/wiki/Zebra_Puzzle>'
using drools5.
I defined a class named 'House' to represent the data, and the corresponding
enums as well : Color.java, Nation.java, Pet.java, Drink.java,
Cigarette.java, here are those sources:
House.java:
public class House {
// 颜色
public Color color;
// 房子从左数的位置 1-5
public int position;
public Nation nation;
public Pet pet;
public Drink drink;
public Cigarette cigarette;
......
Color.java:
public enum Color {
red, yellow, blue, green, ivory
}
Nation.java:
public enum Nation {
englishman, spaniard, norwegian, ukrainian, japanese
}
Pet.java:
public enum Pet {
dog, fox, snails, horse, zebra
}
Drink.java:
public enum Drink {
orangeJuice, tea, coffee, milk, water
}
Cigarette.java:
public enum Cigarette {
kools, chesterfields, winston, luckyStrike, parliaments
}
And this is my drl file:
package com.sample
import com.sample.fh.*
rule "英国人住在红色的房子里"
when
$h1:House(nation == Nation.englishman, color != Color.red)
$h2:House(color == Color.red)
then
System.out.println("英国人(englishman)住在红色(red)的房子里");
modify($h2){setColor($h1.color)};
modify($h1){setColor(Color.red)};
end
rule "西班牙人养了一条狗"
when
$h1:House(nation == Nation.spaniard)
$h2:House(pet == Pet.dog, nation != Nation.spaniard)
then
System.out.println("西班牙人(spaniard)养了一条狗(dog)");
modify($h2){setPet($h1.pet)};
modify($h1){setPet(Pet.dog)};
end
rule "挪威人住在左边的第一个房子里"
when
$h1:House(position == 1, nation != Nation.norwegian)
$h2:House(nation == Nation.norwegian)
then
System.out.println("挪威人(norwegian)住在左边的第一个房子里");
modify($h2){setNation($h1.nation)};
modify($h1){setNation(Nation.norwegian)};
end
rule "黄房子里的人喜欢抽kools牌的香烟"
when
$h1:House(color == Color.yellow, cigarette != Cigarette.kools)
$h2:House(cigarette == Cigarette.kools)
then
System.out.println("黄房子(yellow)里的人喜欢抽kools牌的香烟");
modify($h2){setCigarette($h1.cigarette)};
modify($h1){setCigarette(Cigarette.kools)};
end
rule "抽chesterfields牌香烟的人与养狐狸的人是邻居"
when
$h1:House(cigarette == Cigarette.chesterfields, pet != Pet.fox)
$h2:House(pet == Pet.fox)
$h3:House(eval(position - $h2.position == 1) || eval(position -
$h2.position == -1))
eval($h1.position - $h2.position != 1 && $h1.position - $h2.position
!= -1)
then
System.out.println("抽chesterfields牌香烟的人与养狐狸(fox)的人是邻居");
int tmp = $h3.position;
modify($h3){setPosition($h1.position)};
modify($h1){setPosition(tmp)};
end
rule "抽chesterfields牌香烟的人与养狐狸的人是同一人"
when
$h1:House(cigarette == Cigarette.chesterfields, pet == Pet.fox)
$h2:House(eval(position - $h1.position == 1) || eval(position -
$h1.position == -1))
then
System.out.println("抽chesterfields牌香烟的人与养狐狸的人是同一人");
modify($h1){setPet($h2.pet)};
modify($h2){setPet(Pet.fox)};
end
rule "挪威人住在蓝色的房子旁边"
when
$h1:House(nation == Nation.norwegian)
$h2:House(color == Color.blue)
$h3:House(eval(position - $h2.position == 1) || eval(position -
$h2.position == -1))
eval($h1.position - $h2.position != 1 && $h1.position - $h2.position
!= -1)
then
System.out.println("挪威人(norwegian)住在蓝色(blue)的房子旁边");
modify($h1){setNation($h3.nation)};
modify($h3){setNation(Nation.norwegian)};
end
rule "抽winston牌香烟的人养了一只蜗牛"
when
$h1:House(cigarette == Cigarette.winston)
$h2:House(pet == Pet.snails, cigarette != Cigarette.winston)
then
System.out.println("抽winston牌香烟的人养了一只蜗牛(Snails)");
modify($h2){setPet($h1.pet)};
modify($h1){setPet(Pet.snails)};
end
rule "抽LuckyStrike牌香烟的人喜欢喝桔子汁"
when
$h1:House(cigarette == Cigarette.luckyStrike)
$h2:House(drink == Drink.orangeJuice, cigarette !=
Cigarette.luckyStrike)
then
System.out.println("抽Lucky Strike牌香烟的人喜欢喝桔子汁(orange juice)");
modify($h2){setDrink($h1.drink)};
modify($h1){setDrink(Drink.orangeJuice)};
end
rule "乌克兰人喜欢喝茶"
when
$h1:House(nation == Nation.ukrainian)
$h2:House(drink == Drink.tea, nation != Nation.ukrainian)
then
System.out.println("乌克兰人(ukrainian)喜欢喝茶(tea)");
modify($h2){setDrink($h1.drink)};
modify($h1){setDrink(Drink.tea)};
end
rule "日本人抽parliaments牌的烟"
when
$h1:House(nation == Nation.japanese)
$h2:House(cigarette == Cigarette.parliaments, nation !=
Nation.japanese)
then
System.out.println("日本人(japanese)抽parliaments牌的烟");
modify($h2){setCigarette($h1.cigarette)};
modify($h1){setCigarette(Cigarette.parliaments)}
end
rule "抽kools牌的香烟的人与养马的人是邻居"
when
$h1:House(cigarette == Cigarette.kools)
$h2:House(pet == Pet.horse)
$h3:House(eval(position - $h2.position == 1) || eval(position -
$h2.position == -1))
eval($h1.position - $h2.position != 1 && $h1.position - $h2.position
!= -1)
then
System.out.println("抽kools牌的香烟的人与养马(horse)的人是邻居");
modify($h1){setCigarette($h3.cigarette)};
modify($h3){setCigarette(Cigarette.kools)};
end
rule "喜欢喝咖啡的人住在绿房子里"
when
$h1:House(drink == Drink.coffee)
$h2:House(color == Color.green, drink != Drink.coffee)
then
System.out.println("喜欢喝咖啡(coffee)的人住在绿(green)房子里");
modify($h2){setColor($h1.color)};
modify($h1){setColor(Color.green)};
end
rule "绿房子在象牙白房子的右边"
when
$h1:House(color == Color.green, position != 1)
$h2:House(color == Color.ivory, position != 5)
$h3:House(eval(position == $h2.position + 1), color != Color.green)
then
System.out.println("绿(green)房子在象牙白(ivory)房子的右边(图中的右边)");
modify($h1){setColor($h3.color)};
modify($h3){setColor(Color.green)};
end
rule "白房子已经在最右边了"
when
$h1:House(color == Color.ivory, position == 5)
$h2:House(color == Color.green, position != 1)
$h3:House(eval(position == $h2.position -1))
then
System.out.println("白房子已经在最右边了");
$h3.setPosition($h1.position);
$h1.setPosition($h2.position - 1);
update($h3);
update($h1);
end
rule "绿房子已经在最左边了"
when
$h1:House(color == Color.green, position == 1)
$h2:House(color == Color.ivory, position != 5)
$h3:House(eval(position == $h2.position + 1))
then
System.out.println("绿房子已经在最左边了");
modify($h3){setPosition($h1.position)};
modify($h1){setPosition($h2.position + 1)};
end
rule "绿房子在最左边且白房子在最右边"
when
$h1:House(color == Color.green, position == 1)
$h2:House(color == Color.ivory, position == 5)
$h3:House()
$h4:House(eval(position - $h3.position == 1))
then
System.out.println("绿房子在最左边且白房子在最右边");
modify($h2){setPosition($h3.position)};
modify($h3){setPosition(5)};
modify($h1){setPosition($h4.position)};
modify($h4){setPosition(1)};
end
rule "中间那个房子里的人喜欢喝牛奶"
when
$h1:House(position == 3, drink != Drink.milk)
$h2:House(drink == Drink.milk)
then
System.out.println("中间那个房子里的人喜欢喝牛奶");
modify($h2){setDrink($h1.drink))};
modify($h1){setDrink(Drink.milk)};
end
rule "output"
when
$h1:House(position == 1)
$h2:House(position == 2)
$h3:House(position == 3)
$h4:House(position == 4)
$h5:House(position == 5)
House(nation == Nation.englishman, color == Color.red)
House(nation == Nation.spaniard, pet == Pet.dog)
House(position == 1, nation == Nation.norwegian)
House(color == Color.yellow, cigarette == Cigarette.kools)
$h6:House(cigarette == Cigarette.chesterfields)
$h7:House(pet == Pet.fox)
eval($h6.position - $h7.position == 1 || $h6.position - $h7.position
== -1)
$h8:House(nation == Nation.norwegian)
$h9:House(color == Color.blue)
eval($h8.position - $h9.position == 1 || $h8.position - $h9.position
== -1)
House(cigarette == Cigarette.winston, pet == Pet.snails)
House(cigarette == Cigarette.luckyStrike, drink ==
Drink.orangeJuice)
House(nation == Nation.ukrainian, drink == Drink.tea)
House(cigarette == Cigarette.parliaments, nation == Nation.japanese)
$h10:House(cigarette == Cigarette.kools)
$h11:House(pet == Pet.horse)
eval($h10.position - $h11.position == 1 || $h10.position -
$h11.position == -1)
House(drink == Drink.coffee, color == Color.green)
$h12:House(color == Color.green)
$h13:House(color == Color.ivory)
eval($h12.position - $h13.position == 1)
House(position == 3, drink == Drink.milk)
then
System.out.println("从左到右:");
System.out.println("第一间房子是"+$h1.color+"色的;住着"+$h1.nation+"人;养"+$h1.pet+"宠物;抽"+$h1.cigarette+"牌香烟;喝"+$h1.drink+"饮料;");
System.out.println("第二间房子是"+$h2.color+"色的;住着"+$h2.nation+"人;养"+$h2.pet+"宠物;抽"+$h2.cigarette+"牌香烟;喝"+$h2.drink+"饮料;");
System.out.println("第三间房子是"+$h3.color+"色的;住着"+$h3.nation+"人;养"+$h3.pet+"宠物;抽"+$h3.cigarette+"牌香烟;喝"+$h3.drink+"饮料;");
System.out.println("第四间房子是"+$h4.color+"色的;住着"+$h4.nation+"人;养"+$h4.pet+"宠物;抽"+$h4.cigarette+"牌香烟;喝"+$h4.drink+"饮料;");
System.out.println("第五间房子是"+$h5.color+"色的;住着"+$h5.nation+"人;养"+$h5.pet+"宠物;抽"+$h5.cigarette+"牌香烟;喝"+$h5.drink+"饮料;");
end
There's some unicode character in the file.But it shouldn't bother the
compilation>...<
The rule named 'output' describes when the computation should stop. The
other rules are absorbed from the original 'Zebra puzzle' problem and each
making a little change to the working memory in order to 'approach' the
solution...(I don't know if I'm doing this wrong..)
No matter how I modify this program, it always result in an infinite loop...
For example, the console prints these messages repeatedly:
白房子已经在最右边了
抽chesterfields牌香烟的人与养狐狸的人是同一人
抽kools牌的香烟的人与养马(horse)的人是邻居
黄房子(yellow)里的人喜欢抽kools牌的香烟
抽kools牌的香烟的人与养马(horse)的人是邻居
黄房子(yellow)里的人喜欢抽kools牌的香烟
抽kools牌的香烟的人与养马(horse)的人是邻居
黄房子(yellow)里的人喜欢抽kools牌的香烟
抽kools牌的香烟的人与养马(horse)的人是邻居
黄房子(yellow)里的人喜欢抽kools牌的香烟
抽kools牌的香烟的人与养马(horse)的人是邻居
黄房子(yellow)里的人喜欢抽kools牌的香烟
......................
I worked quite much time on this problem till now, and I referenced another
solution which is programmed in prolog, but still I didn't figured out the
drools solution to this problem.
Could somebody give a hint? Any help is appreciated,
Thanks!
--
Regards.
Miles. Wen
13 years, 5 months
drools-ant
by Abhay B. Chaware
How do I compile only rule (.drl) files into packages ? I read that drools-ant can be used to compile rules, but not getting any information about using the drools-ant. How do I use drools-ant ? Is that the only way to compile rules ? Any other options ?
-abhay
13 years, 5 months
How does Drools support Notifications?
by Jay
Hi there,
As I associate Notification and Deadline with HumanTask node, that is,
extend the HumanTask node with params of Notification(e.g. notification
name/priority/description/recipients..etc), params of Deadline(StartDeadline
and EndDeadline).
What I want is: if deadline is missed, an email notification can be sent to
the recipients. And according to the 2nd constructor of
TaskService(org.drools.task.service.TaskService) and
DefaultEscalatedDeadlineHandler, I can construct the TaskService with a
DefaultEscalatedDeadlineHandler to handle the notification in TaskServer.
But, will it work? According to WS-HumanTask spec, if a task has not been in
"InProgress" state, notification sent, but where will it check the state of
task? Because if the task has been in "InProgress" state, notification can't
be sent. EndDeadline also has a similar story.
So how does Drools support Notification? Because according to this
post:http://blog.athico.com/2008/09/drools-and-ws-humantask.html, it has
been fixed.
Any advice is highly appreciated.
Thanks,
Jay
--
View this message in context: http://drools.46999.n3.nabble.com/How-does-Drools-support-Notifications-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 5 months