RuntimeDroolsException as Solver concludes execution
by dweppenaar
Hi.
I am experiencing the following exception:
org.drools.RuntimeDroolsException: Exception executing ReturnValue
constraint org.drools.rule.ReturnValueRestriction@a5f6c234 :
java.lang.NullPointerException.
The rule that is causing the exception to occur is the following:
rule "spreadOvertime"
when
$violatingTask :
MaintenanceTask(eval(maintenanceSlot.getAvailability() == 1), motor != null,
maintenanceTechnician != null, $overtimeTaskID : id);
ArrayList( $numberOfViolations : size ) from collect(
MaintenanceTask(
id == ($overtimeTaskID + 1) ||
id == ($overtimeTaskID + 2) ||
id == ($overtimeTaskID - 1) ||
id == ($overtimeTaskID - 2),
eval(maintenanceSlot.getAvailability() >= 1) ) );
then
insertLogical(new IntConstraintOccurrence("spreadOvertime",
ConstraintType.NEGATIVE_SOFT,
$numberOfViolations, $violatingTask, $numberOfViolations));
//System.out.println("Rule Fired: spreadOvertime ( number of
violations:" + $numberOfViolations + " for task " + $violatingTask + ")");
end
The purpose of the rule is to spread the closer to normal maintenance
shifts.
Just to clarrify what the objects are:
MaintenanceTask: Consists of a MaintenanceSlot, MaintenanceTechnician and
Motor
MaintenanceSlot: Day, Timeslot, Availability and Index
The 'availability' of a MaintenanceSlot specifies whether it is considered
Overtime, ProductionTime or Normal Maintenance
This exception is thrown at the end of solving as the solver (I presume) is
supposed to return the best solution. The score is calculating and updating
but at the end of the specified step count, this exception occurs.
If I comment this rule out, no exception.
Any help would be appreciated!
Regards,
De Ville
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/RuntimeDroolsExceptio...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 8 months
Running Sub-process only once in rule flow
by Adeyinka Timi
Hi,
Is it possible to set some kind of RUN-ONLY-ONCE restriction on a
sub-process in a rule flow, to avoid running this process multiple times in
the case of a cycle in the rule-flow?
-Ade
15 years, 9 months
Load balancing, fail-over, replication
by Bertrand Grottier
Hello,
I am evaluating the possible use of Drools to implement a pricing engine. Until now, I have developped my prototypes on my own computer; everything was fine.
However, if Drools is retained, it will be used in a shared environment. More precisely, a shared platform is provided for different customers, each one having its own set of rules. This raises issues such as load balancing, replication and so on.
Which architecture is recommended ? How can these issues be addressed ?
This is very fuzzy to me. I am not even sure that they are Drools related...
Thank you in advance for your help.
Regards,
Benoît
_________________________________________________________________
Consultez vos emails Orange, Gmail, Yahoo!, Free ... directement depuis HOTMAIL !
http://www.windowslive.fr/hotmail/agregation/
15 years, 9 months
Drools3 syntax fails in Drools5
by agopalkr
I am trying to migrate from Drools3 to Drools
There is one particular syntax which works in Drools3 but not in Drools5.
rule "Test Long2"
when
//Gives error in D5
m : MyLongValue(id1)
then
System.out.println("did it2:::::" + m);
end
The question I have is
1. What is the meaning of the syntax MyLongValue(id1) ?
2. What is the equivalent syntax in Drools5?
MyLongValue {
private Long id1;
public void setId1(Long x) {
id1 = x;
}
public Long getId1() {
return id1;
}
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools3-syntax-fails-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 9 months
RPC call exception with drools guvnor
by Dominik Hüttner
Hi,
I use drools guvnor first version 5.1.0, but now I have to use 5.0.1.
On the PC, it has to work on, the following error is produced, when I enter
the drools webpage:
22.04.2010 14:24:03 org.apache.catalina.core.ApplicationContext log
SCHWERWIEGEND: Exception while dispatching incoming RPC call
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.extract(
ServerSerializationStreamReader.java:617)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.readInt(
ServerSerializationStreamReader.java:432)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.prepar
eToRead(AbstractSerializationStreamReader.java:38)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.prepareT
oRead(ServerSerializationStreamReader.java:383)
at
com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:234)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServic
eServlet.java:163)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServ
let.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at
org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServle
tRequest.java:53)
at
org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:583)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
That computer has Windows XP Prof SP3, Tomcat 6.0.20, Java jdk 6.0 update
17. The same error occurs with the jboss standalone. Version 5.1.0 works
fine.
On another computer, that is configured nearly the same (WinXP prof SP3,
Tomcat 6.0.20, java jdk 6.0 update 7) all works fine.
Maybe someone can even give me an advise, what could be the problem, or
maybe have a solution.
Kind regards,
Dominik
15 years, 9 months
Newbie on drools and servlets
by kuena
Hi,
I know a question has been asked before about drools and servlets, so I
apologise in advance. May someone please advice me on the best way of making
Drools and servlets friends in my application ;-) I want to use drools to
re-implement the servlet shown below. I have also attached the flow.
In brief my scenario works as follows:
User submits a form to request info; result map is returned; if size >3
refine else return results. Refine will require a page to be generated
asking user how to refine. The user answer will then be used to generate
result.
I have a feeling I might just need to add another node (e.g. event wait or
human task) between the refine action and the rule flow group node. Would
want to avoid that but not sure how will resume flow after refine. I would
be grateful for any pointers.
http://n3.nabble.com/forum/FileDownload.jtp?type=n&id=742273&name=flow.png
public class GeneratorServlet extends HttpServlet {
//declarations
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
//declarations
if(request.getAttribute("resultsMap") != null){
map = (Map) request.getAttribute("resultsMap");
//Render results i.e. present results to user if list is
short
if(map.size() <= maxOutput){
htmlPage.render(map, out, templatePath);
}
//list is long, ask how to shorten the list
else if (map.size() > maxOutput){
dialogSession.setAttribute("storedResultsMap", map);
htmlPage.refine(map, out, templatePath);
}
}
else{ // resultsMap is null
if(dialogSession.getAttribute("storedResultsMap")!= null){
map = (Map)
dialogSession.getAttribute("storedResultsMap");
String criteriaSelection =
request.getParameter("refineChoice");
if(criteriaSelection.equalsIgnoreCase("choice1")){
htmlPage.render(choice1Map, out, templatePath);
}
else if(criteriaSelection.equalsIgnoreCase("choice2")){
htmlPage.render(choice2Map, out, templatePath);
}
else {
htmlPage.render(map, out, templatePath);
}
}
}
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Newbie-on-drools-and-...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 9 months
NullPointerException during removing knowledge packages
by Piotr Jedrychowski
Hello.
I have a problem with removing knowledge packages. During running this
source code
Collection<KnowledgePackage> knowledgePackages =
knowledgeBase.getKnowledgePackages();
if (knowledgePackages != null) {
List<String> packageNames = new ArrayList<String>();
for (KnowledgePackage singlePackage : knowledgePackages) {
packageNames.add(singlePackage.getName());
}
for (String singlePackageName : packageNames) {
knowledgeBase.removeKnowledgePackage(singlePackageName);
}
}
I'm getting NullPointerException with this StackTrace:
java.lang.NullPointerException
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:235)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:366)
at
org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:712)
at
org.drools.common.AbstractRuleBase.removePackage(AbstractRuleBase.java:640)
at
org.drools.impl.KnowledgeBaseImpl.removeKnowledgePackage(KnowledgeBaseImpl.java:166)
I found this links in Internet:
http://seamframework.org/Community/DroolsGuvnorCacheIssue
http://lists.jboss.org/pipermail/rules-users/2007-November/003917.html
Maybe someone had similar problem and could help me?
I'm using:
* JBoss 4.2.3.GA
* Drools 5.0
Regards,
Piotr
15 years, 9 months
Problems with result mapping for custom workitems
by PAYET, Manuel
Hello everyone, I have a problem using result mapping in custom workitems when I try to set an attribute of an object as one of the result:
I make the following mapping in Result Mapping of my workitem:
Parameter Variable
message workmodel.message
and all I have is
Could not find variable scope for variable workmodel.message
when trying to complete Work Item workitem_test
Continuing without setting variable.
I hope, someone can help me, I tried all that I could think about...
you will find below all my project, sorry for the long post...:
/forum/src/main/java/mpayet/test/forum/App.java
=======================================================================
package mpayet.test.forum;
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderErrors;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import workDefinitions.WorkitemTest;
import workDefinitions.Workmodel;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello World!");
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
final Map<String, Object> map = new HashMap<String, Object>();
map.put("workmodel", new Workmodel());
session.getWorkItemManager().registerWorkItemHandler("workitem_test", new WorkitemTest(session));
session.startProcess("flow", map);
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("flow.rf"),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
=======================================================================
/forum/src/main/java/workDefinitions/WorkitemTest.java
=======================================================================
package workDefinitions;
import java.util.HashMap;
import java.util.Map;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.WorkItem;
import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
public class WorkitemTest implements WorkItemHandler {
final StatefulKnowledgeSession session;
public WorkitemTest(final StatefulKnowledgeSession session) {
this.session = session;
}
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
final Map<String, Object> mapResult = new HashMap<String, Object>();
mapResult.put("message", "message");
mapResult.put("nombre", 1);
manager.completeWorkItem(workItem.getId(), mapResult);
}
}
=======================================================================
/forum/src/main/java/workDefinitions/Workmodel.java
=======================================================================
package workDefinitions;
public class Workmodel {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
=======================================================================
/forum/src/main/java/META-INF/DefinitionsWorkitem.conf
=======================================================================
import org.drools.process.core.datatype.impl.type.StringDataType;
import org.drools.process.core.datatype.impl.type.IntegerDataType;
[
// exemple de workitem
[
"name" : "workitem_test",
"parameters" : [
"typeObjet" : new StringDataType(),
"nombre" : new IntegerDataType()
],
"displayName" : "workitem test",
"icon" : "icons/icone_service.gif"
]
]
=======================================================================
/forum/src/main/java/flow.rf
=======================================================================
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
type="RuleFlow" name="flow" id="flow" package-name="com.mpayet.test" routerLayout="1" >
<header>
<imports>
<import name="workDefinitions.Workmodel" />
</imports>
<variables>
<variable name="workmodel" >
<type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="workDefinitions.Workmodel" />
</variable>
</variables>
</header>
<nodes>
<actionNode id="13" name="affichage variable" x="16" y="176" width="161" height="48" >
<action type="expression" dialect="mvel" >var model =(Workmodel)context.getVariable("workmodel")
System.out.println(model.message)</action>
</actionNode>
<end id="8" name="End" x="72" y="256" width="48" height="48" />
<start id="1" name="Start" x="72" y="16" width="48" height="48" />
<workItem id="20" name="workitem test" x="46" y="97" width="100" height="48" >
<work name="workitem_test" >
<parameter name="nombre" >
<type name="org.drools.process.core.datatype.impl.type.IntegerDataType" />
</parameter>
<parameter name="typeObjet" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
</work>
<mapping type="out" from="message" to="workmodel.message" />
</workItem>
</nodes>
<connections>
<connection from="20" to="13" />
<connection from="13" to="8" />
<connection from="1" to="20" />
</connections>
</process>
=====================================================================
Thank you very much if you took the time to think about my problem,
Manuel PAYET
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. 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.
15 years, 9 months
Using Drools for Batch Data Validation
by Richard, Rene
Hello,
I am new to Drools (1 day of reading and watching video podcasts etc...). We have a requirement for our project where we'll have an input table HSQLDB table and some validation rules we need to apply on the data in the table. Some tables will have > 45 000 records or more. Would this kind of Batch validation be something Drools is good at? Rules can change over time and the table definition can also.
It seems like Drools would be a good tool for doing the validation. I'm imagining an input table and an output table. The input table is the table we want to run validation for. The output table is a table that has had validation run against it an an extra column with a validation pass/fail status for reporting purposes...
Thanks in advance
Rene
15 years, 9 months