ClassCastException: MVELDialectConfiguration cannot be cast to DialectConfiguration
by Peach Wyss
Hy
I get the following error:
...
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:313)
...
... 42 more
Caused by: java.lang.ClassCastException: org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration cannot be cast to org.drools.compiler.DialectConfiguration
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:308)
... 51 more
I'm using drools in a maven project, pom.xml:
...
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.5.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.5.0.Final</version>
</dependency>
...
What could cause this error?
Thanks for your help.
Kind regards,
Peter
11 years, 9 months
UnsupportedOperationException intermitently
by erolagnab
We've upgraded Drools 5.1 to 5.4.0.Final. Everything is great with new
incremental build change-set.However, occasionally we get this error (so
far, 2 different stack trace)java.lang.UnsupportedOperationException
at org.drools.reteoo.BaseLeftTuple.getObject(BaseLeftTuple.java:589)
at
org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:273)
at
org.drools.reteoo.LeftTupleSource.doModifyLeftTuple(LeftTupleSource.java:297)
at
org.drools.reteoo.AbstractTerminalNode.modifyLeftTuple(AbstractTerminalNode.java:104)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateModifyObject(CompositeLeftTupleSinkAdapter.java:260)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyObject(CompositeLeftTupleSinkAdapter.java:275)
at
org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:170)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateModifyObject(SingleObjectSinkAdapter.java:68)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:157) at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:432)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:157) at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:421)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:470)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:370)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:317)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:312)AND
java.lang.UnsupportedOperationException at
org.drools.reteoo.BaseLeftTuple.getPrevious(BaseLeftTuple.java:478)
at org.drools.core.util.LeftTupleList.remove(LeftTupleList.java:84)
at org.drools.core.util.LeftTupleList.removeAdd(LeftTupleList.java:65)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:302) at
org.drools.reteoo.LeftTupleSource.doModifyLeftTuple(LeftTupleSource.java:297)
at
org.drools.reteoo.LeftTupleSource.modifyLeftTuple(LeftTupleSource.java:271)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:429) at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateModifyObject(CompositeLeftTupleSinkAdapter.java:260)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyObject(CompositeLeftTupleSinkAdapter.java:275)
at
org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:170)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateModifyObject(SingleObjectSinkAdapter.java:68)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:157) at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:432)
at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:157) at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:421)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:470)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:370)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:317)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:312)I've
searched around and saw https://issues.jboss.org/browse/JBRULES-3713. I've
downloaded the test program and load our rules but can't reproduce the
issue. The similarity between our rules and rules in the test case is that
we do have a rule matched and perform an update on the fact.With my limited
knowledge of drools and how it works internally, i've run out of ideas.SOS,
please help!!!Regards,Trung
--
View this message in context: http://drools.46999.n3.nabble.com/UnsupportedOperationException-intermite...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Accessing my Drools rules as a web service in Drools 5.5?
by lamenramen
Hello,
I have built a few simple rules, and I would like to enable access of these
rules as a RESTful service. Smartphones, and non-java clients are going to
call them, pass in some JSON, and then get an answer back in JSON. (Or XML,
that's fine too).
Could someone tell me how to, the general sense (or specific sense if you're
feeling generous), how to start?
I am using Drools 5.5; I saw this thing called a Drools Execution Server
that is a war file in the Drools 5.4 documentation, but in 5.5 has that been
deprecated? I do not see anything in the 5.5 docs about this, so what is
the new way of doing this?
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Accessing-my-Drools-rules-as-a-web-serv...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Example code to test an object that contains a collection of other objects?
by lamenramen
Hi,
I have read around for an entire day but still can not figure out how to
write the following in DRL syntax:
"When a person has a an advanced degree, print 'person is educated'"
A person has many degrees. So, I have a Person POJO and a Degree POJO.
A Person object has a field callled "degrees", which is nothing more than an
ArrayList<Degree>.
A degree has nothing but a name field, which is a String.
In regular java, it would be:
for (Degree d : person.getDegrees() {
if (d == "phd" || d == "ms" || d == "jd" || d == "md") {
System.out.println("person is highly educated");
}
}
I can not do this in the Guvnor either.
I've tried using a contains keyword but I just can't my rule to fire.
Simple rules otherwise fire just fine ,so my plumbing is all wired up
correctly.
--
View this message in context: http://drools.46999.n3.nabble.com/Example-code-to-test-an-object-that-con...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Only simple types?
by Wolfgang Laun
Here I have lots of classes with Boolean methods such as
Boolean isSomething()
and a large number of rules where
X(... something == true,...)
used to work fine not too long ago. But 5.5.0 and 5.4.0 claim that
this isn't correct:
Unable to Analyse Expression adult == true:
[Error: unable to resolve method using strict-mode: express.Person.adult()]
[Near : {... adult == true ....}]
This used to work in 5.3.0.
Trying to avoid the Boolean/bool discrepancy, I replaced true with the object:
X(... something == Boolean.TRUE,...)
but being as strict as possible doesn't work, too, neither in 5.4.0nor 5.5.0.
This used to work in 5.3.0, and so did the very simple
X(... something,...)
but not any more.
The fact that all of the following work in 5.5.0
X(... isSomething(),... )
X(... isSomething() == true,... )
X(... isSomething() == Boolean.TRUE,... )
is certainly nice, but:
Since I'm going to have to change a ton of rules: Which of these
versions should I use to have best chances for future compatibility?
Thanks
-W
11 years, 9 months
WorkingMemoryEntryPoints
by Per Sterner
Hello,
We are upgrading our project from Drools 5.3 to Drools 5.5.0 and got
some problems. We tried to locate the problem and it seems there is a
problem with the WorkingMemoryEntryPoints?
In our project everything is in WorkingMemoryEntryPoints. In this
example all facts are in "test_me". We removed the dependencies to the
memoryentrypoint and then it works.
The problem is with the WorkingMemoryEntryPoints that the Rule "TestRule
- set state_2" is triggered more then two times.
The output is:
SETTING STATE 2
STATE 2
STATE 1
STATE 1
SETTING STATE 2
STATE 2
SETTING STATE 2
STATE 2
SETTING STATE 2
STATE 2
[...]
If we remove the entrypoints the output is:
SETTING STATE 2
STATE 2
SETTING STATE 2
STATE 2
[And that's it]
Is there something with the usage from the WorkingMemoryEntryPoints or
is this a bug?
Regards,
Per Sterner
TestObject.java
---------------------------------------------------------------------------
public class TestObject {
private String stateAsString;
public void setStateAsString(final String stateAsString) {
this.stateAsString = stateAsString;
}
public String getStateAsString() {
return stateAsString;
}
}
---------------------------------------------------------------------------
MyTicker.java
---------------------------------------------------------------------------
public class MyTicker {
private final long timeStart;
private long time;
public MyTicker() {
timeStart = System.currentTimeMillis();
}
public long getTime() {
return time;
}
public void setTime(final long time) {
this.time = time;
}
public long getTimeStart() {
return timeStart;
}
}
---------------------------------------------------------------------------
DroolsTest.java
---------------------------------------------------------------------------
public class DroolsTest {
public static void main(final String[] args) {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("TestDrools.drl",
Init.class), ResourceType.DRL);
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile
\"HelloWorld.drl\".");
}
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
final KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
final StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
TestObject testObject1 = new TestObject();
testObject1.setStateAsString("STATE_1");
TestObject testObject2 = new TestObject();
testObject2.setStateAsString("STATE_1");
TestCache testCache = new TestCache();
MyTicker ticker = new MyTicker();
ticker.setTime(System.currentTimeMillis());
WorkingMemoryEntryPoint e =
ksession.getWorkingMemoryEntryPoint("test_me");
e.insert(testObject1);
e.insert(testObject2);
e.insert(testCache);
FactHandle tickerHandle = e.insert(ticker);
DroolsTickerThread droolsTickerThread = new
DroolsTickerThread("droolstickerthread", ticker, ksession, tickerHandle);
droolsTickerThread.start();
}
public static class DroolsTickerThread extends Thread {
private final DroolsTicker ticker;
private final StatefulKnowledgeSession ksession;
private final FactHandle tickerHandle;
public DroolsTickerThread(final String name, final DroolsTicker
ticker, final StatefulKnowledgeSession ksession,
final FactHandle tickerHandle) {
super(name);
this.ticker = ticker;
this.ksession = ksession;
this.tickerHandle = tickerHandle;
}
@Override
public void run() {
WorkingMemoryEntryPoint entry =
ksession.getWorkingMemoryEntryPoint("test_me");
while (!isInterrupted()) {
try {
ticker.setTime(System.currentTimeMillis());
entry.update(tickerHandle, ticker);
ksession.fireAllRules();
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
};
}
}
---------------------------------------------------------------------------
TestCache.java
---------------------------------------------------------------------------
public class TestCache {
private long lastCheckTimestamp = 0;
public void setLastCheckTimestamp(final long lastCheckTimestamp) {
this.lastCheckTimestamp = lastCheckTimestamp;
}
public long getLastCheckTimestamp() {
return lastCheckTimestamp;
}
}
---------------------------------------------------------------------------
TestDrools.drl
---------------------------------------------------------------------------
package de.drools.test
import de.drools.test.*;
rule "TestRule - set state_2"
dialect "mvel"
when
$obj: TestObject (
stateAsString == "STATE_1"
) from entry-point "test_me"
$cache: TestCache ( ) from entry-point "test_me"
DroolsTicker(
$time : time,
(time - $cache.lastCheckTimestamp) > 10000
) from entry-point "test_me"
then
System.out.println("SETTING STATE 2");
modify ($obj) {stateAsString = "STATE_2"};
modify ($cache) {lastCheckTimestamp = $time };
end
rule "TestRule - sysout state_2"
when
TestObject (
stateAsString == "STATE_2"
) from entry-point "test_me"
then
System.out.println("STATE 2");
end
rule "TestRule - sysout state_1"
when
TestObject (
stateAsString == "STATE_1"
) from entry-point "test_me"
then
System.out.println("STATE 1");
end
---------------------------------------------------------------------------
11 years, 9 months
Comparing KnowledgePackages for Equality
by gqmulligan
If I wanted to compare two knowledge packages to find out if they are the
"same" how would I do so?
More specifically if I deserialize the same knowledge package twice how can
I compare the two in a way that will return true signifying they are the
same?
Using the equals method will not work since that simply does identity
comparisons. This is causing big problems for me right now because
hibernate always thinks packages are dirty and is constantly updating them
to the database when they do not need to be.
Any suggestions are much appreciated as this has become an urgent issue.
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/Comparing-KnowledgePackages-for-Equalit...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Decision table convertation issue
by mikhal
Hi,
I'm trying to play with decision tables as with a possible rule description
way and have faced
strange behavior as for me. When I upload a XLS spreadsheet got from Drools
examples
ExamplePolicyPricing.xls it uploads and converts to the inner web format
correctly.
But there is a difference between rule sources (use View Sources from
drop-down menu)
before and after convertation:
Before:
/11. | // rule values at C11, header at C5
12. | rule "Pricing bracket_11"
13. | when
14. | Driver(age >= 18, age <= 24, locationRiskProfile == "MED")
15. | policy: Policy(type == "FIRE_THEFT")
16. | then
17. | policy.setBasePrice(200);
18. | System.out.println("Priors not relevant");
19. | end/
After:
/12. | //from row number: 2
13. | //Created from row 11
14. | rule "Row 2 Pricing bracket (converted on 21-Mar-2013 16:10:31)"
15. | dialect "mvel"
16. | when
17. | policy: Policy(type == "FIRE_THEFT")
18. | then
19. | policy.setBasePrice(200);
20. | System.out.println("Priors not relevant");
21. | end/
A result of the convertation is loosing conditions
/Driver(age >= 18, age <= 24, locationRiskProfile == "MED")./
Looks like a bug. Still maybe it is known issue? Could anyone explain
please.
Thanks.
Denis
--
View this message in context: http://drools.46999.n3.nabble.com/Decision-table-convertation-issue-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months