Re: [rules-users] Drools, slf4j and Eclipse Error on DroolsTest.Java
by Inastrol
Figured out the problem. Didn't have Maven installed as a plug-in
correctly. The book I'm using to learn Drools, didn't include that step.
Terry Moriarty wrote:
> This isn't my code. It's created when a Drools project is created in
> Eclipse. I guess that's why this is so frustrating. It's supposed to
> demonstrate a very simple Drools program and I can't get it to work.
> It's hard to debug someone else's code when you don't know the
> language yet.
>
> Code is kSession.insert(message);
>
> Thanks
>
> sdjoe [via Drools] wrote:
>
>> Hard to say without seeing your code. Can you post it here and point
>> out where the NPE is happening on line 23?
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://drools.46999.n3.nabble.com/Drools-slf4j-and-Eclipse-Error-on-Drool...
>>
>> To unsubscribe from Drools, slf4j and Eclipse Error on
>> DroolsTest.Java, click here
>> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscr...>.
>> NAML
>> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_vi...>
>>
>
>------------------------------------------------------------------------
>
>package com.sample;
>
>import org.kie.api.KieServices;
>import org.kie.api.runtime.KieContainer;
>import org.kie.api.runtime.KieSession;
>
>/**
> * This is a sample class to launch a rule.
> */
>public class DroolsTest {
>
> public static final void main(String[] args) {
> try {
> // load up the knowledge base
> KieServices ks = KieServices.Factory.get();
> KieContainer kContainer = ks.getKieClasspathContainer();
> KieSession kSession = kContainer.newKieSession("ksession-rules");
>
> // go !
> Message message = new Message();
> message.setMessage("Hello World");
> message.setStatus(Message.HELLO);
> kSession.insert(message);
> kSession.fireAllRules();
> } catch (Throwable t) {
> t.printStackTrace();
> }
> }
>
> public static class Message {
>
> public static final int HELLO = 0;
> public static final int GOODBYE = 1;
>
> private String message;
>
> private int status;
>
> public String getMessage() {
> return this.message;
> }
>
> public void setMessage(String message) {
> this.message = message;
> }
>
> public int getStatus() {
> return this.status;
> }
>
> public void setStatus(int status) {
> this.status = status;
> }
>
> }
>
>}
>
>
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-slf4j-and-Eclipse-Error-on-Drool...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Drools 6 and Gradle?
by Andrew Berman
Hello,
I keep running into an issue where Drools is looking for a pom.properties
file and I get an error since I'm using Gradle. Does Drools depend on
Maven? I noticed there is a lot of code looking for Maven and pom.xml and
pom.properties, why is that?
Thanks!
11 years, 9 months
ReteOO, KnowledgeBase and KnowledgeSession relation
by Harpreet Singh
Hi,
I understand that the ReteOO network is built when a KnowledgeBase is created. Can you please tell me:
- if any modifications are made to this network after a session (say StatefulKnowledgeSession) has been created from this KnowledgeBase?
- any optimizations made at the session level? (such that time taken to fire rules decreases when certain set of facts are re-inserted and rules re-executed)
I could not find any explanation in Drools Expert documentation regarding the above two points. Any pointers explaining the relation between ReteOO, KnowledgeBase and KnowledgeSession will be helpful.
Thanks.
11 years, 9 months
java dialect and declared types
by pmander
If I declare a type in a drl and reference the attributes in a rule then all
is fine for either dialect. But, if one of the attributes is a java class
that has been compiled and inserted then under the java dialect only I get a
compilation error: rule compilation error the field ... is not visible
for example
declare DroolsTransaction
ORG : String
PRODUCT : String
raw : Transaction
end
rule "create classes"
salience 100
when
$t : Transaction()
then
insert(new DroolsTransaction((String)$t.fieldFor("ORG"),
(String)$t.fieldFor("PRODUCT"), $t));
end
I insert Transaction objects in the session and this works fine for the
following rule if I have the dialect set to mvel.
rule "1"
when
$t : DroolsTransaction(ORG == "A" , PRODUCT == "001", raw.complicated())
then
do something
end
but when I switch dialects to java, the compilation complains that raw is
not visible.
I guess drools is dynamically creating the DroolsTransaction object with
private fields... and I need public accessors - how to define them?
--
View this message in context: http://drools.46999.n3.nabble.com/java-dialect-and-declared-types-tp40278...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Re: [rules-users] Drools, slf4j and Eclipse Error on DroolsTest.Java
by Inastrol
This isn't my code. It's created when a Drools project is created in
Eclipse. I guess that's why this is so frustrating. It's supposed to
demonstrate a very simple Drools program and I can't get it to work.
It's hard to debug someone else's code when you don't know the language yet.
Code is kSession.insert(message);
Thanks
sdjoe [via Drools] wrote:
> Hard to say without seeing your code. Can you post it here and point
> out where the NPE is happening on line 23?
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://drools.46999.n3.nabble.com/Drools-slf4j-and-Eclipse-Error-on-Drool...
>
> To unsubscribe from Drools, slf4j and Eclipse Error on
> DroolsTest.Java, click here
> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscr...>.
> NAML
> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_vi...>
>
package com.sample;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
/**
* This is a sample class to launch a rule.
*/
public class DroolsTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("ksession-rules");
// go !
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
kSession.insert(message);
kSession.fireAllRules();
} catch (Throwable t) {
t.printStackTrace();
}
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-slf4j-and-Eclipse-Error-on-Drool...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Moves Defined from Current State
by jonathan.labin
I'm using Optaplanner 6.0.1 and I'm having trouble defining a type of move
that I'd like to define.
In my domain, there may be an opportunity to split the value assigned to one
entity across two entities. For example:
E1=5 could become E2=2, E3=3
The trouble is that in some cases this split can be performed more than one
way. The above example could also be split to become E2=1,E3=4, ...
At the time that the Moves is created (and initialized with entities) by the
MoveFactory, there are values assigned to the entities but those values may
change and shouldn't be part of the Move (am I right about that?).
So when Moves are executed, the values assigned could be considered to
create a set of Moves based on the current state but aren't Moves already
created long before then?
Is there a way to generate moves based on the current state? How do you
ensure they are not cached ore reused after that step?
Thanks,
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Moves-Defined-from-Current-State-tp4027...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Null Pointer Exception with 10K+ kBase objects
by jhusby
I'm trying to stress-test Drools to see what its limits are, and I stumbled
across a NPE when I have a large amount of facts in a stateful
knowledgebase:
java.lang.NullPointerException
at
org.drools.core.phreak.PhreakTimerNode.doPropagateChildLeftTuple(PhreakTimerNode.java:355)
at
org.drools.core.phreak.PhreakTimerNode.doPropagateChildLeftTuples(PhreakTimerNode.java:325)
at org.drools.core.phreak.PhreakTimerNode.doNode(PhreakTimerNode.java:72)
at
org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:357)
at
org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:161)
at
org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)
at
org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:200)
at
org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:67)
at
org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:935)
at
org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1200)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:957)
at
org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:931)
at
org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:256)
I have a little program that creates, populates, fires, and destroys a
session repeatedly. With 10K objects in the knowledge base, I get the NPE
the first time I loop through my program, but not subsequently (probably
because by the subsequent executions things have been cached). With 100K
objects, I get the exception most times. With 1M objects, I get the NPE
every time.
Am I doing anything wrong or is it simply taking so long to execute all the
rules that something times out? Is there a timeout param I could set?
Thank you!
Joseph
--
View this message in context: http://drools.46999.n3.nabble.com/Null-Pointer-Exception-with-10K-kBase-o...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Drools as osgi bundle in Jboss AS
by km.sujeet
Hi,
I am trying to run "Hello World" using drools as osgi bundle in Jboss AS.
Deployed below jars to Jboss container :
drools-compiler-6.0.0.Beta1.jar
drools-core-6.0.0.Beta1.jar
drools-templates-6.0.0.Beta1.jar
kie-api-6.0.0.Beta1.jar
kie-internal-6.0.0.beta1.jar
While deploying my own bundle to Jboss which has "Hello World" Drools
application, I get below exception:
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:321)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:307)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:192)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:170)
at
org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:22)
at
org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:74)
at
org.drools.container.spring.beans.KnowledgeBaseBeanFactory.afterPropertiesSet(KnowledgeBaseBeanFactory.java:80)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 34 more
Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in
the classpath
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:100)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:61)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:317)
... 42 more
Then added "org.eclipse.jdt.core_3.8.3.v20130121-145325.jar" to classpath of
OSGI bundle (Hello World Bundle) and deployed again.
Above exception has got resolved, but application is not working.
Code below :
public void start(){
logger.info("started.");
System.out.println("Hello World in client!! ");
//droolsSession = createKnowledgeSession();
MessageTest message = new MessageTest();
message.setMessage("Testing Hello World");
message.setStatus(MessageTest.HELLO);
droolsSession.insert(message);
droolsSession.fireAllRules();
}
@SuppressWarnings("deprecation")
private StatefulKnowledgeSession createKnowledgeSession() {
System.out.println("Inside createKnowledgeSession!! ");
KnowledgeBuilderFactoryServiceImpl knowledgeBuilderFactoryServiceImpl =
new KnowledgeBuilderFactoryServiceImpl();
KnowledgeBuilder kbuilder =
knowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder();
kbuilder.add((Resource) new ClassPathResource("Sample.drl"),
ResourceType.DRL);
System.out.println("Completed createKnowledgeSession!! ");
if (kbuilder.hasErrors()) {
if (kbuilder.getErrors().size() > 0) {
for (KnowledgeBuilderError kerror : kbuilder.getErrors()) {
System.err.println(kerror);
}
}
}
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
return kbase.newStatefulKnowledgeSession();
//return kbase.newStatefulKnowledgeSession();
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-as-osgi-bundle-in-Jboss-AS-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
OptaPlanner vehicle routing problem with "multiple depots"
by milenko
Dear OptaPlanner users,
I am working for a small company located in Munich and have a software
problem, which I would like to solve with OptaPlnner.
In our case, we have multiple technicians which are starting their work each
day from different locations (e.g. their homes).
Each technician has to serve customers at different locations.
Each customers has his own time window for the visit (earliest arrival time,
wait time, planned start time, planned end time, real end time, …).
On one hand the route of each technician should be optimized.
Also the planned customer time window should be met optimally.
There should not be many empty gaps in the time schedule of single
technicians.
For me this looks somehow similar like the vehicle routing problem with time
window.
In our case we have the following similarities:
Customer= Customer
Vehicle = Technician
Time windows = Time windows + additional time windows
Depot = We have many Depots (Starting locations) for each single technician
I do not know how I could transfer the parameter capacity of the vehicle –
probably I don’t need it..
What I tried: I changed the parameters in the xml-input file to change the
location position of the customers and also the different time windows.
But I don’t succeed to add additional depots (customers)? Does somebody has
an idea how to realize that?
Best regards.
Milenko
--
View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-vehicle-routing-problem-wit...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months