Re: [rules-users] java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
by Manasi
Hi,
I am also getting same error when trying to a call rule stored in guvnor.
Following error I am getting:
Exception in thread "main" java.lang.ClassCastException:
[Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package
at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:82)
at org.drools.agent.URLScanner.readPackage(URLScanner.java:171)
at org.drools.agent.URLScanner.getChangeSet(URLScanner.java:143)
at org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:119)
at org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:427)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:379)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:364)
at org.drools.agent.RuleAgent.init(RuleAgent.java:264)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:204)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:164)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:273)
I am using Drools 5.4 version.
The error is coming when trying to get the RuleAgent:
RuleAgent agent = RuleAgent.newRuleAgent("/com/model/drools.properties");
drools.properties contains:
url =
http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/FeltKnapRes...
name=guvnorAgent
enableBasicAuthentication=True
username=admin
password=admin
FeltKnapRestriktionerKundeMedAnl is the package name I have created in
guvnor ,and I want to call one of the rule in this package.
Thanks,
Manasi
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-Lorg-drool...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Fire Rule in Stateless Knowledge Session
by snehils
Hi,
I am new in Drools. I am using Drools version 5.1.0
My requirement is kind of request response, where I have to perform some
checks for the request and respond the result. Hence, I decided to go with
stateless knowledge session.
I have prepared .DRL file and it contains set of rules. When some request
receives I have to identify the rule(s) belongs to that request and then
fire the rule(s).
I am not able to figure out how to categories the rules request wise in DRL
file? Also, how to fire only those rules which belongs to the category.
For example, there are three kinds of requests Rq1, Rq2 and Rq3. There are
rules in DRL file: R1, R2, R3, R4 and R5. R1, R2 belongs to Rq1, R3 belongs
to Rq2 and R4, R5 belongs to Rq3.
When some request receives only its belonging rules should be fired. For
example, on receiving of Rq2 only R3 should be fired.
Please provide me some code snipped or link.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Fire-Rule-in-Stateless-Knowledge-Sessio...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Problem with Banking Tutorial
by Stefan Schuster
Hello,
I have a problem with the banking tutorial number 3, which is part of the
examples of drools expert.
It simply adds some Numbers as facts, and retracts them in an increasing
order.
It is very short, therefore I post the whole Code:
BankingExample3.java
_________________________________________________
package org.drools.tutorials.banking;
public class BankingExample3 {
public static void main(String[] args) {
Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(4),
wrap(1), wrap(5)};
new RuleRunner().runRules( new String[] { "Example3.drl" },
numbers );
}
private static Integer wrap(int i) {
return new Integer(i);
}
}
_________________________________________________
Example3.drl:
_________________________________________________
package org.drools.tutorials.banking
rule "Rule 01"
when
$number : Number()
not Number( intValue < $number.intValue )
then
System.out.println("Number found with value: " + $number.intValue()
);
retract( $number );
end
_________________________________________________
Output:
_________________________________________________
Loading file: Example3.drl
Inserting fact: 3
Inserting fact: 1
Inserting fact: 4
Inserting fact: 1
Inserting fact: 5
Number found with value: 1
Number found with value: 1
Number found with value: 3
Number found with value: 4
Number found with value: 5
_________________________________________________
that seams absolute logically to me.
But now I alter the Numbers in the Java-Part:
Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(2)};
and the output destroys everything I thought I understood:
Loading file: Example3.drl
Inserting fact: 3
Inserting fact: 1
Inserting fact: 2
Number found with value: 1
Number found with value: 3
Number found with value: 2
Can someone reproduce this behavior?? It seams absolutely strange to me. I
would have expected the order 1,2,3. Any explanations?
Thanks in advance for helping me!
12 years, 9 months
Guvnor: Accessing Bound Variable in "Then" Statement
by Vann_the_Red
Hello. I started with a search and didn't find an answer. I apologize if my
search-fu was lacking today.
I'm a non-developer tasked with rules creation and testing using guvnor. I
have found some scenarios where I can bind a variable to either the whole
input model or a fact in the input model and then later access those in the
output model by selecting "Bound Variable" from the popup box in the Then
statement. In other scenarios, "Bound Variable" is not an option (only
Literal or Formula). What must I do to be able to access the bound
variables from the When statement(s) in the Then statement(s)?
TIA,
Vann
This is a repost because I wasn't on the mailing list yet and I gather most
didn't see it. Apologies again.
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Accessing-Bound-Variable-in-Then...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Guvnor-5.5
by Ricardo
Is any one tried guvnor-5.5 in websphere application server?
What happen to the conponents.xml?
Why guvnor is tightly coupled with jbossAS even each version (jbossAS) got
separate war file?
this seems a big impediment for using guvnor as rule authoring tools.
Is one knows well aware these and already know how to deal this, please
advise me?
-----
with kind regards,
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-5-5-tp4022096.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
[Optaplanner] No-arg constructor for BendableScoreDefinition
by jonathan.labin
Is there an example that uses BendableScore?
I'm trying to convert my app from using HardSoftScore to BendableScore and
I've run into my first issue:
Changing from:
@XStreamConverter(value = XStreamScoreConverter.class, types =
{HardSoftLongScoreDefinition.class})
to
@XStreamConverter(value = XStreamScoreConverter.class, types =
{BendableScoreDefinition.class})
throws:
Caused by: java.lang.IllegalArgumentException: The scoreDefinitionClass
(class
org.optaplanner.core.impl.score.buildin.bendable.BendableScoreDefinition)
does not have a public no-arg constructor.
The answer to this issue would be helpful but I'll probably hit other bumps
along the way. Does anyone have an example that uses BendableScore?
Thanks,
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-No-arg-constructor-for-Bend...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Shared Facts across nodes
by mauro
Hello all,
After searching the web and Drools forums for a couple of days, I couldn't
find a solution to the problem I've got to solve. Anyway, if there's a
thread pointing at the same problem, I apologize and please, let me know
where it is.
My current scenario involves a Drools cluster and demands high availability
and scalability of nodes.
I have to provide a pool of rules (Guvnor should easily handle that) and a
set of servers to process facts against those rules.
This is where I'm stuck at.
I need to make sure all generated facts are shared across drools servers at
the time they get into the cluster.
In other words, what I need is a kind of shared (and persistent) session,
and this session should contain unique facts, so the nodes don't waste time
processing what has already been processed by another node. Also, session
response time is critical.
Since I'm new to the Drools world, maybe I'm missing some important aspects
here, however, as far as I understood, Drools should be able to supply my
requirements.
Already read about Drools-Grid (Is it still alive? Being developed?
Reliable?) and JBoss Infinispan. Both seem to help on solving this
requirement, but I'm not sure whether they're the correct tools to attach to
the arch and get to the solution.
Moreover, I have to make sure an instance of Guvnor can share rules with
other instances being queried by the Drools servers.
How can I solve the problems?
Thank you in advance,
Mauro
--
View this message in context: http://drools.46999.n3.nabble.com/Shared-Facts-across-nodes-tp4023210.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Optaplan6.0.0Beta1:chaining-simpleScore OK, DRL Score corruption
by Paul T
Requirement:Equip to tasks scheduling.Earlier tasks may not exceed a waittime
to latest endtime for each job.
2 JOBs to plan each with 2 identical TASKs with only 1 EQUIPMENT anchor:
J1 comprises T1,T2 and J2 comprises T1,T2.
problem Fact: EQUIPMENT E1
planning Entity: TASK T1|duration=3|waittime=2 and
T2|duration=5|waittime=3
OptaPlan Schedule attempt
-------------------------
anchor(E1:T1J1,T1J2,T2J1,T2J2) - so T1J1 is pos1,T1J2 is pos2 etc :
timings are 3+3+5+5 and respective waittimes are 2,2,3,3
Rule: get latest ending task by JOB and punish if waittime is exceeded
between the tasks for that specific JOB.
J1 latestendtime=11 which is T2J1
J2 latestendtime=16 which is T2J2
Punish if any task endtime for JOB exceeds waittime (so for J1:
T2J1-T1J1=(11-6-2)*-1 = -3 (SOFT)
- I believe that the score function remembers J1,T2J1 in position 3 and
T1J1 in position 1 with SOFT score -3
OptaPlan Schedule attempt
-------------------------
anchor(E1:T1J1,T2J2,T2J1,T1J2) - so T1J1 is pos1,T2J2 is pos2 etc :
timings are 3+5+5+3 and respective waittimes are 2,3,3,2
Rule: get latest ending task by JOB and punish if waittime is exceeded
between JOBs
J1 latestendtime=13 which is T2J1
J2 latestendtime=16 which is T1J2
Punish if any task endtime for JOB exceeds waittime (so for J1:
T2J1-T1J1=(13-6-2)*-1 = -5 (SOFT)
- I believe that the score function remembers J1,T2J1 in position 3 and
T1J1 in position 1 with SOFT score -5
Score corruption seems to occur as the DRL scoring function has 2 identical
set of entities/values but with different score results!
J1,T2J1 in position 3 and T1J1 in position 1 with SOFT score -3
J1,T2J1 in position 3 and T1J1 in position 1 with SOFT score -5
What has happened is that J2 has swapped its tasks around which are not(?)
taken into account for a chaining DRL score function and
hence does not see them as different.
Q?: Am I correct in my assumption that the DRL score function has
insufficient data to compare for my requirement?
Q?: If so any ideas to resolve?
--
View this message in context: http://drools.46999.n3.nabble.com/Optaplan6-0-0Beta1-chaining-simpleScore...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months