Drools Java/EJB Deployment
by swaroop
Hi,
I want to deploy the .DRL,.DRT and Decision tables on to some app
server(Tomcat/JBoss) and access the decision entities using an exposed
business method. Please suggest some approaches and samples. I am using
change-set for loading rules, decisiontables, ruleflows .I Have my object
model converted to a jar. Iam using stateful session.
Thanks
Swaroop
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Java-EJB-Deployment-tp3662685p36...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
using CE accumulate
by bobbi_80
Hi,
I have the following bean and trying to run "accumulate" to get the average
of CPU usage from a cluster.
public static class cpuTracker{
private String machinename;
private String averageCPU;
}
My rule is as follows.
rule check
when
$aggr : Number() from accumulate(cpuTracker($avg :
Integer.parseInt(averageCPU.split("\\.")[0])), average($avg))
then
System.out.println(" Average value : " + $aggr);
end
If the averageCPU is an integer type then accumulate works fine but my
problem is that it is string type and I am trying to convert it to integer
from a rule file and it throws a bunch of compile time errors.
any help in resolving it or some workaround is highly appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/using-CE-accumulate-tp3662339p3662339.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
ProcessEventListener event order
by Carlos Villegas
Hi,
I'm testing the ProcessEventListener on a simple process and I get the
"after" events in reverse order.
For example,
Process completed : 1283915643204
Node left: 5: 1283915643268
Node triggered: 5: 1283915643268
Node left: 4: 1283915643268
Node triggered: 4: 1283915643269
Node left: 3: 1283915643269
Node triggered: 3: 1283915643270
Node left: 2: 1283915643270
Node triggered: 2: 1283915643270
Node left: 1: 1283915643270
Node triggered: 1: 1283915643271
Node left: 0: 1283915643271
Node triggered: 0: 1283915643271
Process started : 1283915643271
I'm just printing the node id and the time in milliseconds.
Is this the way is supposed to be?
I guess technically "after" could be anytime after, but if I use the
afterProcessStarted event, I get it after the whole process has
completed!, which it's not useful at all.
The "before" events work as expected I think.
I'm using Drools Flow 5.1.0.
Thanks,
Carlos
12 years, 10 months
Null pointer exception after adding When condtion in Guvunor
by JimK
Using the latest JBPM installer demo setup, I have a simple program. It has
an object called person with a name and a salary. In guvonor there is a
simple rule that I scaled back from the original to try to see what is
happening. If I have a condition (salary >= 5000) it gives a null
exception, if I remove the condition it works fine. The new fact is inserted
and I can see it from my program. Just starting experimenting with guvonor
and have been following the threads on changeset but don't have a complete
grasp on it yet.
Thanks in advance,
Jim K.
rule "PersonWIthHighIncome"
no-loop true
dialect "mvel"
when
Person( salary >= 5000 )
then
Person fact0 = new Person();
fact0.setName( "Joe" );
fact0.setSalary( 34465 );
insert(fact0 );
end
This results in the following exception:
java.lang.NullPointerException
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:148)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1016)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:785)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:657)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:190)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:169)
at simpleBank.SimpleBank.createKnowledgeBase(SimpleBank.java:64)
at simpleBank.SimpleBank.main(SimpleBank.java:27)
Code calling the package
package simpleBank;
import java.util.ArrayList;
import java.util.Iterator;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.agent.KnowledgeAgent;
import org.drools.agent.KnowledgeAgentConfiguration;
import org.drools.agent.KnowledgeAgentFactory;
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.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class SimpleBank {
public static void main(String[] args) {
try {
// load up the knowledge base
//KnowledgeBase kbase = readKnowledgeBase();
KnowledgeBase kbase = createKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
//KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "Test2", 1);
// go ! insert one person
Person person = new Person();
person.setSalary((long) 6000);
person.setName("Jim");
System.out.println(person.getName());
ksession.insert(person);
assertTrue(ksession.getFactCount() == 1);
ksession.fireAllRules();
// rules should have added another fact
assertTrue(ksession.getFactCount() != 1);
ArrayList<Person> listoffacts = new ArrayList(ksession.getObjects());
System.out.println(listoffacts.size());
Iterator<Person> itr = listoffacts.iterator();
while (itr.hasNext()){
Person element = itr.next();
System.out.println(element.getName() + ":" +
element.getSalary().toString());
}
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase createKnowledgeBase() throws Exception{
KnowledgeAgentConfiguration kaconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty( "drools.agent.scanDirectories", "false" );
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "test
agent", kaconf );
kagent.applyChangeSet(ResourceFactory.newUrlResource(
"http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Sale..."
));
// kagent.applyChangeSet(
ResourceFactory.newClassPathResource("ChangeSet.xml"));
return kagent.getKnowledgeBase();
}
private static void assertTrue(boolean b) {
if (b)
{
System.out.println("Good number of facts");
}
else
{
System.out.println("Bad number of facts");
}
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Null-pointer-exception-after-adding-Whe...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Drools 5.3 on Glassfish
by Chris Selwyn
I have just started looking at Drools 5.3 with a view to running the
Guvnor on Glassfish.
I have been using Drools 5.1 Guvnor on Glassfish 2.1 very happily for
some time but I thought that I should look at upgrading.
In fact, some time ago, I posted instructions here on how to setup
authentication for Guvnor against a Glassfish realm.
However, I notice that there are now different Guvnor binaries for
several different ASs but that list does not include Glassfish.
Since Glassfish 2.1 includes Tomcat as its JSP/Servlet container I have
used the Tomcat version and on first inspection it appears to work.
Have other users tried this combination? Did it work/not work for you?
Chris
12 years, 10 months