Create a new package in Drools Guvnor repository
by nagarajt
Hi All,
I am using guvnor-distribution-5.3.0.Beta1. I copied
guvnor-5.3.0.Beta1-tomcat-6.0.war from binaries directory into my tomcat
webapps folder (renamed the war file to drools-guvnor.war)
My question is how to create a new package in Drools guvnor repository from
our source.
(we need to create package and deploy rules from our source files)
repository points to
*http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/*
I want to create a new package name (GreetingTable) in the above repository.
How to do that in my source code?
Waiting for early reply
Regards
Nagaraj
--
View this message in context: http://drools.46999.n3.nabble.com/Create-a-new-package-in-Drools-Guvnor-r...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Guvnor - Issues with repository lock on Tomcat re-deployment
by Patricia Bogoevici
I ran Guvnor 5.1 under Tomcat6. If I am using Tomcat manager to re-deploy Guvnor, I get this error about the repository lock:
Caused by: org.drools.repository.RulesRepositoryException: javax.jcr.RepositoryException: The repository home /MY_SERVER_PATH/guvnor/WEB-INF/classes/repository appears to be already locked by the current process.
To fix the lock error I had to stop Tomcat, upload the new Guvnor war, and start Tomcat. It is pretty inconvenient that one has to restart the whole server, as that would disrupt any other application that is deployed on the same server.
I noticed that another user on this forum mentioned the same repository lock error, but on a WebSphere 7 server. (http://drools.46999.n3.nabble.com/Can-Guvnor-provide-client-management-AP...)
I also checked the JackRabbit source code, and Wiki, and the documentation says that this error happens when the repository is not properly closed.
Can anyone from the Drools-Guvnor team add more details about this? Is this a JackRabbit issue, or a Drools-Guvnor?
thx,
--Patricia
13 years, 3 months
(no subject)
by Manohar Kokkula
Hi to All,
I am new to Drools 5.0...
I created three classes(Student, College and StudentCollege) and Decistion
table(manohar.xls) like this:-
Student.java:
package com.model;
public class Student {
private int age;
private int marks;
public String department;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
}
College.java:
package com.model;
public class College {
private String ranking;
private String location;
public String status;
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public void setRanking(String ranking) {
this.ranking = ranking;
}
public String getRanking() {
return ranking;
}
}
StudentCollege.java:
package com.model;
import java.io.IOException;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.DecisionTableConfiguration;
import org.drools.builder.DecisionTableInputType;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.compiler.DecisionTableFactory;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class Student_College {
public static void main(String args[])
{
Student s=new Student();
College c=new College();
s.setAge(18);
s.setMarks(85);
c.setRanking("A");
c.setLocation("Delhi");
try
{
KnowledgeBase kbase = readBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
ksession.insert(s);
ksession.insert(c);
ksession.fireAllRules();
System.out.println("Department is
"+s.getDepartment());
System.out.println("Status is " + c.getStatus());
ksession.dispose();
}
catch(Exception e)
{
System.out.println("Error is "+e);
}
}
private static KnowledgeBase readBase()
{
DecisionTableConfiguration dconf =
KnowledgeBuilderFactory.newDecisionTableConfiguration();
dconf.setInputType(DecisionTableInputType.XLS);
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("manohar.xls",
Student_College.class), ResourceType.DTABLE, dconf);
//Printing the rules in detail
String drlString = null;
try {
drlString =
DecisionTableFactory.loadFromInputStream(ResourceFactory.newClassPathResource("com/model/manohar.xls").getInputStream(),
dconf);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("..........."+drlString);
if(kbuilder.hasErrors())
{
throw new
RuntimeException(kbuilder.getErrors().toString());
}
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
}
manohar.xls:
RuleSet
com.model
Import
com.model.Student, com.model.College
RuleTable for gettingthe Department and Status of the College
CONDITION
CONDITION
CONDITION
CONDITION
ACTION
ACTION
$s:Student
$s:Student
$c:College
$c:College
age==
marks==
ranking==
location==
$s.setDepartment($param);
$c.setStatus($param);
18
85
A
Delhi
Science
AICTE
18
90
B
Kanpur
Science
AICTE
20
90
A
Mumbai
Maths
AICTE
23
87
C
Hyderabad
Physics
AICTE
I am getting following errors while executing the StudentCollege.java,
Please help me in getting output...
Error is java.lang.RuntimeException: Duplicate declaration for variable
'$s' in the rule 'for gettingthe Department and Status of the College_10'
: [Rule name='for gettingthe Department and Status of the College_10']
Duplicate declaration for variable '$c' in the rule 'for gettingthe
Department and Status of the College_10' : [Rule name='for gettingthe
Department and Status of the College_10']
Duplicate declaration for variable '$s' in the rule 'for gettingthe
Department and Status of the College_11' : [Rule name='for gettingthe
Department and Status of the College_11']
Duplicate declaration for variable '$c' in the rule 'for gettingthe
Department and Status of the College_11' : [Rule name='for gettingthe
Department and Status of the College_11']
Duplicate declaration for variable '$s' in the rule 'for gettingthe
Department and Status of the College_12' : [Rule name='for gettingthe
Department and Status of the College_12']
Duplicate declaration for variable '$c' in the rule 'for gettingthe
Department and Status of the College_12' : [Rule name='for gettingthe
Department and Status of the College_12']
Duplicate declaration for variable '$s' in the rule 'for gettingthe
Department and Status of the College_13' : [Rule name='for gettingthe
Department and Status of the College_13']
Duplicate declaration for variable '$c' in the rule 'for gettingthe
Department and Status of the College_13' : [Rule name='for gettingthe
Department and Status of the College_13']
Rule Compilation error : [Rule name='for gettingthe Department and Status
of the College_10']
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_10_0.java
(7:513) : Science cannot be resolved
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_10_0.java
(8:538) : AICTE cannot be resolved
Rule Compilation error : [Rule name='for gettingthe Department and Status
of the College_12']
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_12_0.java
(7:513) : Maths cannot be resolved
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_12_0.java
(8:536) : AICTE cannot be resolved
Rule Compilation error : [Rule name='for gettingthe Department and Status
of the College_11']
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_11_0.java
(7:513) : Science cannot be resolved
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_11_0.java
(8:538) : AICTE cannot be resolved
Rule Compilation error : [Rule name='for gettingthe Department and Status
of the College_13']
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_13_0.java
(7:513) : Physics cannot be resolved
com/model/Rule_for__gettingthe_Department_and_Status_of_the_College_13_0.java
(8:538) : AICTE cannot be resolved
Thanks and Regards
Manohar Kokkula
Mailto: manohar.kokkula(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
13 years, 3 months
Quotes in decision tables are escaped
by kennywest
Hi all,
I am experiencing the problem that is described here:
http://efreedom.com/Question/1-4874717/Drools-Rules-Quotes-Auto-Escape-Co...
>From what I can see, this has nothing to do with guvnor, since I am using XL
decision tables without Guvnor. I have an XL where I have an action column
that looks like this:
row x : ACTION
row x +1: = empty row =
row x + 2: StringBuilder sb = new StringBuilder();
sb.append($param)
row x + 3: Perform some action
row x + 4: $a.get("test")
What this should do is compile it to a DRL file with the following portion:
StringBuilder sb = new StringBuilder();
sb.append($a.get("test"));
However, this gets translated to:
StringBuilder sb = new StringBuilder();
sb.append($a.get(\"test\"));
... which is wrong. Any ideas why this is happening? (using drools 5.2.0
final)
--
View this message in context: http://drools.46999.n3.nabble.com/Quotes-in-decision-tables-are-escaped-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
DroolsCompilerAntTask bugs?
by lhorton
I think I have found a couple of bugs in DroolsCompilerAntTask. I am using
it to compile xls decision tables. My config for the compiler is:
<compiler srcdir="${build.web.dir}/packages/venue"
tofile="${build.web.dir}/packages/venue/venue.pkg"
binformat="package" bintype="knowledge" classpathref="model.classpath">
<include name="*.xls" />
</compiler>
I copied the source and added debug log entries. I found two problems:
(1) in the method compileAndAddFiles(KnowledgeBuilder kbuilder), there is a
call to getDroolsPackageFileList(). The call is supposed to return any
package file names in the srcdir, but it is instead it is returning the xls
spreadsheet file names. Then again within compileAndAddFiles, there is a
call to getFileList(), which also returns the xls file names. As a result,
each file gets added to the rule base twice.
(2) in method compileAndAddFile(KnowledgeBuilder kbuilder, String fileName),
the code to compile a spreadsheet (file extension XLSFILEEXTENSION) throws
exception with message "Property storage size inconsistent with block
chain." I changed the source to use a file resource instead of a reader
resource:
kbuilder.add(ResourceFactory.newFileResource(new File(this.srcdir,
fileName)), ResourceType.DTABLE,
dtableconfiguration);
and then the compile works OK.
--
View this message in context: http://drools.46999.n3.nabble.com/DroolsCompilerAntTask-bugs-tp3279120p32...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Drools 5.2 performance building KnowledgeBase
by darktyco
Has anyone out there experienced any slowdowns using Drools 5.2 to build a
knowledge base? I have around 700 drl files (containing anywhere from 1 to
30 rules each) and the time to build a KnowledgeBase with them has increased
from about 10 minutes in Drools 5.1 to 90 minutes in Drools 5.2. I realize I
have a slow computer here, but the time difference between the two versions
is staggering.
I have already been serializing the KnowledgeBase object for performance
reasons and even loading the serialized KnowledgeBase takes about 3-4x
longer in 5.2 than in 5.1. Am I doing something wrong here? Here are some
code snippets of how I am building and loading the kbase:
//////////////////////// Building
final KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
final List<File> drlFiles = getAllDrlFiles(directory);
for (final File name : drlFiles) {
kBuilder.add(ResourceFactory.newFileResource(name),
ResourceType.DRL);
}
if (kBuilder.hasErrors()) {
// ....
}
final KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
ObjectOutputStream oos = null;
try {
oos = new DroolsObjectOutputStream(new FileOutputStream(pkgFile));
oos.writeObject(kBase);
} catch (...) {
// ....
}
//////////////////////// Loading
ois = new DroolsObjectInputStream(new FileInputStream(pkgFile));
final KnowledgeBase kBase = (KnowledgeBase) ois.readObject();
final StatefulKnowledgeSession ksession =
kBase.newStatefulKnowledgeSession();
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-2-performance-building-Knowled...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Eclipse reports error when declaring FactType
by FrankVhh
Hi all,
This question might make me look like a bit of a moaner. Then again, you
shouldn't be a member of an internet forum if you'd worry about what other
people think of you. Therefore:
If you declare a type in one of your rule files, and use that type in
another drl file, Eclipse will return an error message claiming that the
type in question does not exist. And actually, he is quite right, as the
type will only start existing when the kbase is created. So, the rules you
created *will* work at runtime (provided you did not commit any other
foolishness).
The thing is, these errors are a bit annoying. Is there any way to
circumvent this, moan-moan ? Or is the only way to get rid of the error
messages to create the objects in java?
Thanks a lot.
Regards,
Frank
--
View this message in context: http://drools.46999.n3.nabble.com/Eclipse-reports-error-when-declaring-Fa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
How to pass global variables to a function called in a condition
by Matthew Erler
In Drools 5 I'm passing in two global Date objects and need to find the difference in days between them. I've discovered that the function parameters (fromDate and toDate in my case) are null in the condition when the function is called, but when the function is called in the consequence they have values. I can see that because the output of the following rule is:
fromDate is null
toDate is null
I'm in dateDiff and the date diff is: 14
I'm guessing that Drools doesn't make globals t available at the point that I need them. Can anyone confirm this and offer a solution?
Here is the rule file itself:
import java.util.Date;
import org.joda.time.DateMidnight;
import org.joda.time.Days;
global java.util.Date fromDate;
global java.util.Date toDate;
rule "dateDiff"
dialect "mvel"
when
eval(getDaysBetweenStartAndEndDate(fromDate, toDate) < 10)
then
System.out.println( "I'm in dateDiff and the date diff is: " + getDaysBetweenStartAndEndDate(fromDate, toDate));
end
function int getDaysBetweenStartAndEndDate(Date fromDate, Date toDate) {
if (fromDate==null) System.out.println("fromDate is null");
if (toDate==null) System.out.println("toDate is null");
return Days.daysBetween(new DateMidnight(fromDate), new DateMidnight(toDate)).getDays();
}
13 years, 3 months