DSL Bug?
by rjr201
I've had the following problem when creating a DSL. Not sure if it's a bug,
but it confused me for a good 40 minutes so thought I'd mention it here in
case others have the same problem..
If I create a DSL like this:
[when]There is a fact {fact_name}{fact_label}={fact_label}:{fact_name}()
And create a rule in the guided editor that has Object as the {fact_name}
and $obj as the {fact_label} I get:
1. | rule "rule"
2. | dialect "mvel"
3. | when
4. | Object$obj:()
5. | then
6. | end
as the source.
At first I thought it was to do with putting quotation marks around the
{}'s. But I've since found that if I put a space between {fact_name} and
{fact_label} I get the expected result of:
1. | rule "rule"
2. | dialect "mvel"
3. | when
4. | $obj:Object()
5. | then
6. | end
Again, sorry if this is down to my limited understanding of DSLs. Any
further insights into why this happens or any other quirks of DSLs would be
greatly appreciated as I'm going to be spending a lot of time with them in
the not too distant future..
Rich.
--
View this message in context: http://drools.46999.n3.nabble.com/DSL-Bug-tp4022209.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
DroolsServiceImplementation - from examples
by MaverickDrools
Hi,
Trying to run the startServers() test at:
https://github.com/droolsjbpm/guvnor/blob/5.5.x/guvnor-webapp-drools/src/...
which gives me an exception:
java.lang.NoClassDefFoundError:
Lorg/drools/guvnor/server/DroolsServiceImplementation;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
at java.lang.Class.getDeclaredFields(Class.java:1743)
at org.junit.runners.model.TestClass.<init>(TestClass.java:40)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:65)
at
org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:59)
at org.jboss.arquillian.junit.Arquillian.<init>(Arquillian.java:50)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at
org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at
org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException:
org.drools.guvnor.server.DroolsServiceImplementation
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 25 more
I'm guessing I need to add a dependency in the pom file to get the
implementation of this class.
org.drools / guvnor-webapp-drools / 5.5.0.Beta1 is a WAR artifact and so
org.drools.guvnor.server.DroolsServiceImplementation resides within a WAR
file. How can I make it accessible to the JUnit that I'm trying to execute?
Thanks,
Aseem
--
View this message in context: http://drools.46999.n3.nabble.com/DroolsServiceImplementation-from-exampl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Guvnor Calendar problem
by Anton Nikulin
Hi
I have such problem. I use Guvnor as a storage for rules, and now i want to
add calendars declaration to some rule. I've done this and in my sources of
these rules i can see:
rule "CalendarTest"
calendars "AUD Home Loans"
no-loop true
dialect "mvel"
when
then
System.out.println("CALENDAR IS WORKING!!!");
end
In my application I use KnowledgeAgent and such configuration to use rules
from Guvnor:
KnowledgeBuilder builder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
builder.add(ResourceFactory.newClassPathResource("ChangeSet.xml"),
ResourceType.CHANGE_SET);
if (builder.hasErrors()) {
throw new RuntimeException(builder.getErrors().toString());
} // creating KnowledgeBase and Session
KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase();
base.addKnowledgePackages(builder.getKnowledgePackages());
StatefulKnowledgeSession session =
base.newStatefulKnowledgeSession();
my ChangeSet.xml looks like this:
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>
<add>
<resource source='
http://localhost:8083/drools-guvnor/rest/packages/magick-model/source'
type='DRL' basicAuthentication="enabled" username="admin" password="admin"/>
</add>
</change-set>
But the problem is when i invoke fureRules this rule with calendars clause
also invokes, even if i don't set any calendar objects to session.
Can you help me what the problem is?
And if i just use local drl file, everything works fine
Thanks, Anton
11 years, 9 months
Uploading JAR using REST
by rjr201
Hi,
I've successfully uploaded a JAR file using the rest api. I can see it under
the model tab of a package in Guvnor. However, when I go to create a rule
using the Guided Editor it tells me that no model has been uploaded.
Does anyone have any ideas why this happens and how to go about solving it?
As always, thanks for any help in advance.
Rich.
--
View this message in context: http://drools.46999.n3.nabble.com/Uploading-JAR-using-REST-tp4022115.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Drools 5.2 -> 5.5 problems
by darktyco
Hey everyone,
I have been running Drools 5.2 for a long time now and decided to try out
Drools 5.5 to see what was new. I felt that 5.2 was always a bit of a memory
hog so I was hoping that 5.5 would be better, however it seems to have
gotten worse. Previously I could run my company's test suite with -Xmx1024m
-XX:MaxPermSize=256m. Now I get:
[Error: Java heap space]
[Near : {... MyDomainObject != CE ....}]
^
[Line: 1, Column: 1]
at
org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:308)
at
org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at
org.drools.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:435)
at
org.drools.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:238)
at
org.drools.rule.constraint.MvelConstraint.createMvelConditionEvaluator(MvelConstraint.java:206)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:190)
at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:157)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at
my.company.KnowledgeBaseStatelessRuleEngine.execute(KnowledgeBaseStatelessRuleEngine.java:48)
I incrementally increased the max heap size in steps of 500m to see when the
heap error would go away and I had to go all the way up to 4000m. Is it
common knowledge that Drools requires more memory since 5.5? Is there
anything our rules could possibly be doing wrong that the newer versions
don't like?
Once I do get the tests running, I am getting a lot of errors about a
comparison to a string with the value of "null":
Exception executing consequence for rule "SomeRule_39" in
my.company.user.rules: [Error: incompatible types in statement: class
java.lang.String (compared from: class
my.company.userdata.intermediate.numbers.TotalScore)]
[Near : {... this != "null" ....}]
^
[Line: 1, Column: 1]
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at
my.company.commons.rules.util.KnowledgeBaseStatelessRuleEngine.execute(KnowledgeBaseStatelessRuleEngine.java:49)
Caused by: [Error: incompatible types in statement: class java.lang.String
(compared from: class my.company.userdata.intermediate.numbers.TotalScore)]
[Near : {... this != "null" ....}]
^
[Line: 1, Column: 1]
at org.mvel2.ast.BinaryOperation.<init>(BinaryOperation.java:84)
at org.mvel2.util.CompilerTools.finalizePayload(CompilerTools.java:118)
at
org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:287)
at
org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62)
at org.mvel2.MVEL.compileExpression(MVEL.java:810)
at
org.drools.base.mvel.MVELCompilationUnit.compile(MVELCompilationUnit.java:435)
at
org.drools.base.mvel.MVELCompilationUnit.getCompiledExpression(MVELCompilationUnit.java:238)
at
org.drools.rule.constraint.MvelConstraint.createMvelConditionEvaluator(MvelConstraint.java:206)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:190)
at
org.drools.rule.constraint.MvelConstraint.isAllowed(MvelConstraint.java:157)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:137)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:192)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:186)
at
my.company.user.rules.Rule_SomeRule_39_e811b8e64e174d6b84ff672feb3172d2.defaultConsequence(Rule_SomeRule_39_e811b8e64e174d6b84ff672feb3172d2.java:8)
at
my.company.user.rules.Rule_SomeRule_39_e811b8e64e174d6b84ff672feb3172d2DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
my.company.user.rules.Rule_SomeRule_39_e811b8e64e174d6b84ff672feb3172d2DefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 37 more
I have checked my DRL sources and verified that I am not doing any null
checks, and I am certainly not doing any "null" checks either. Does anyone
out there happen to know why this error is occuring? The source for that
rule is:
rule "SomeRule_39"
when
subScore1 : SubScore1()
subScore2 : SubScore2()
subScore3 : SubScore3()
subScore4 : SubScore4()
subScore5 : SubScore5()
subScore6 : SubScore6()
subScore7 : SubScore7()
subScore8 : SubScore8()
subScore9 : SubScore9()
subScore10 : SubScore10()
then
TotalScore totalScore = new TotalScore(subScore1.getValue() +
subScore2.getValue() + subScore3.getValue() + subScore4.getValue() +
subScore5.getValue() + subScore6.getValue() + subScore7.getValue() +
subScore8.getValue() + subScore9.getValue() + subScore10.getValue());
insert(totalScore);
end
Thanks for any insight!
-DT
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-2-5-5-problems-tp4022168.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Re: [rules-users] To group some objects by type
by mdzaebel
Mister Nono wrote
> ... only the last car is in the TreeMap
Thats why I said "/you need Lists or Maps as values of the TreeMap/".
*Here is fast solution:*
import Vehicle
import java.util.*
rule "Print grouped vehicles"
when $map : Map() from accumulate ($v : Vehicle($w : wheels),
init(TreeMap map=new TreeMap()),
action( if(map.containsKey($w)) ((List)map.get($w)).add($v);
else map.put($w, new ArrayList(Arrays.asList($v)));),
result(map))
then System.out.println($map);
end
--
View this message in context: http://drools.46999.n3.nabble.com/To-group-some-objects-by-type-tp4022085...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months