5.4.0.Final OSGi bundle with Apache Karaf 2.2.7
by Nicholas Hemley
Hello,
I am having troubles getting the 5.4.0.Final OSGi bundle to install/activate on Apache Karaf 2.2.7.
Note - I have already fixed the JAXB/XJC problem as discussed here:
https://issues.jboss.org/browse/JBRULES-3192
So following from this I have tried two different approaches:
a) Drop the OSGi bundle jars into Karaf deploy/ folder
b) Using Karaf Console
The latter method is discussed here:
http://drools.46999.n3.nabble.com/drools-osgi-issue-td4017799.html
The console session for (b) was as follows:
osgi:install -s wrap:mvn:com.google.protobuf/protobuf-java/2.4.1
osgi:install -s wrap:mvn:org.antlr/antlr-runtime/3.3
osgi:install -s wrap:mvn:javax.persistence/persistence-api/1.0.2
osgi:install -s mvn:org.mvel/mvel2/2.1.0.drools16
osgi:install -s wrap:mvn:com.thoughtworks.xstream/xstream/1.4.2
osgi:install -s wrap:mvn:org.drools/drools-spring/5.4.0.Final
osgi:install -s mvn:org.drools/knowledge-api/5.4.0.Final
osgi:install -s mvn:org.drools/knowledge-internal-api/5.4.0.Final
osgi:install -s mvn:org.drools/drools-core/5.4.0.Final
NullPointerException (no stack trace)
Clearly the 5.4.0.Final bundle, as is, does not work in Apache Karaf 2.2.7.
So my question is this:
Has the fix in the post above been applied to a patch that I can download, please? Or must I wait for 5.5.0.Beta1?
Otherwise, is there a previous version of Drools OSGi bundles that does work with Apache Karaf?
Many thanks for any pointers.
Cheerio,
Nic
14 years
Check problems of conflicts in the rules
by paco
I want to detect the conflict between the rules with Drools Verifier. For
example the first condition of the second rule is present in the first rule
and the actions to perform are the same in both rules as they demonstrate in
the following case. It works very well when these rules belong to the same
drl file.
--------- fichier a.drl---------------------------
rule "a"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0
then
Action1
end
rule "b"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0 && B==1
then
Action1
end
The problem arises when I separated its rules and that I have to put each in
its own file
---------------- a.drl----------------
rule "a"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0
then
Action1
end
------------------b.drl--------------------
rule "b"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0 && B==1
then
Action1
end
I can no longer detect this problem with Drools Verifier.
Does anyone ever encountered this problem?
How can I do to write a small program to audit if this case?
--
View this message in context: http://drools.46999.n3.nabble.com/Check-problems-of-conflicts-in-the-rule...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Giving multiple range values in condition of Decision table
by pratibhapandey
Hello Team,
I have written a condition like this, see the highlighted one..
http://drools.46999.n3.nabble.com/file/n4017965/error.png
I am getting the prob when rule engine parses the range value. When I
generate a DRL out of this sheet what I get is:
rule "Rule 2"
salience 65520
when
lvgBslaData: LeverageBSLAData(((productTypeCode in ('REO' ||
(investmentGroupType == "'TRM')") && (dealLtvNbiExtDebt <= EQUITY)) &&
primaryCollateralType == "0.6")
then
lvgBslaData.setCorpLeverageName( "Hotel Equity ");
end
except of getting the below rule:
rule "Rule 2"
salience 65520
when
lvgBslaData: LeverageBSLAData(((productTypeCode in ('REO','TRM') ||
(investmentGroupType == "EQUITY") &&(dealLtvNbiExtDebt <= 0.6)) &&
primaryCollateralType == "Hotel")
then
lvgBslaData.setCorpLeverageName( "Hotel Equity ");
end
I cannot change the condition except the ordering.. Please tell me how can I
achieve this?
--
View this message in context: http://drools.46999.n3.nabble.com/Giving-multiple-range-values-in-conditi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
getBestSolution not returning the correct Solution?
by Charles
I displayed the score to console on hardConstraintsBroken rule.
rule "hardConstraintsBroken"
dialect "java"
salience -1 // Do the other rules first (optional, for performance)
when
$sd : ServiceRequest( $object : object );
$hardTotal : Number() from accumulate (
IntConstraintOccurrence( $weight : weight ),
sum( $weight ) );
then
System.out.println( $object.getId() + " : " + (- $hardTotal.intValue())
);
scoreHolder.setScore(- $hardTotal.intValue() );
end
I found that the getBestSolution() did not return the correct best solution
based on console output.
For example, in console output
Problem Entity:
O00010440201002 O00010440201003 O00010440201004 O00010440201009
O00010440201010 O00010440201011
Object: O00010440201002 : -5
Object: O00010440201002 : -5
Object: O00010440201010 : -4
Object: O00010440201003 : -5
Object: O00010440201004 : -5
Object: O00010440201011 : -4
Object: O00010440201009 : -1
Object: O00010440201004 : -5
Object: O00010440201010 : -4
Object: O00010440201002 : -5
Object: O00010440201003 : -5
Object: O00010440201011 : -4
Object: O00010440201002 : -5
Object: O00010440201003 : -5
Object: O00010440201004 : -5
Object: O00010440201009 : -1
Object: O00010440201011 : -4
Object: O00010440201003 : -5
Object: O00010440201011 : -4
Object: O00010440201004 : -5
Best Solution return by Solver
O00010440201011 : -1
My expectation
O00010440201009 : -1
Previous implementation in 5.3.0 doesn't have this problem.
Can explain where I might do wrongly?
--
View this message in context: http://drools.46999.n3.nabble.com/getBestSolution-not-returning-the-corre...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Is a single StatefulKnowledgeSession with Distributed Memory cache possible?
by chrisLi
Hi All,
I am working on a banking fraud detection project with Drools Fusion,
which will match a transaction against hunreds of rules to check whether the
transaction is suspicious.
In some rules, I use time-based sliding window to calculate the average
transaction amount of an account in the past 3 or 6 months. One possible
rule will be as below:
rule "Single Large Amount Transaction"
dialect "mvel"
when
$account : Account($number : number)
$averageAmount : BigDecimal() from accumulate(
TransactionCompletedEvent(fromAccountNumber == $account.number,
$amount : amount)
over window:time(90d)
from entry-point TransactionStream,
bigDecimalAverage($amount))
$t1 : TransactionCreatedEvent(fromAccountNumber == $account.number,
amount > $account.creditAmount * 0.5, amount > $averageAmount *
3.0)
from entry-point TransactionStream
then
end
In such cases, the Fusion Engine will hold TransactionCompletedEvent in
its memory for 90 days. And we have about 1 billion Accounts in total, so
the TransactionCompletedEvent will be huge, we will very soon run out of
memory.
I have been blocked here for a long time! Is it possible to distribute a
single StatefulKnowledgeSession in multiple JVMs or machines using
Distributed Memory cache such as Hazelcast? If yes, could you give me some
opinion on the solution? Or is this the problem the Drools Grid project try
to handle? Or there are other techonology to handle large numbers of facts
or events problem?
As far as I know, Drools Grid distribute multilple ksessions on multiple
machines in the Grid, each or several kseesions on one node? Is my
understandings right?
Any response or opinion from you will be appriciated! Thank you very
much!
--
View this message in context: http://drools.46999.n3.nabble.com/Is-a-single-StatefulKnowledgeSession-wi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
jsp, java and drl file
by Brajesh
Hi Friends
I am trying to create a web page with a form, so when we click on submit, we
are redirected to the result web page, but the content of this page will be
generated according to the rules i created in my drl file. Does anyone knows
the easiest way to do this? are they a way to call the drl file from the jsp
file, or the java file?
My Jsp file
<form:form method="post" action="login.htm" commandName="loginForm"
id="loginForm">
<table>
<tr>
<td>Enter username:</td>
<td><form:input path="UserName" style="width:250px"
maxlength="75"/></td>
</tr>
<tr>
<td>Enter password</td>
<td><form:password path="UserPassword" style="width:250px"
maxlength="75"/></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" >
<label>
<input type="submit" value="Save" />
</label>
<label>
<input type="reset" value="clear"/>
</label>
</td>
</tr>
</table>
</form:form>
My controller class
@RequestMapping(value="login.htm", method=RequestMethod.POST)
public String showAffilaiteform(Map<String, Object> model,login
loginform,BindingResult result) {
String target = AFFILIATE_REGISTRATION;
try{
testDAO.drools(loginform);
model.put("affiliateRegistrationForm", new AffiliateUserRegistration());
}catch(Exception e)
{
e.printStackTrace();
}
return target;
}
My TestDao class
public class TestDAO implements ITestDao {
public void drools(login loginform) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "myLog");
ksession.insert(loginform);
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("LoginRules.drl"),
ResourceType.DRL);
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;
}
My DRL file
import com.ri.bean.login;
rule "b"
dialect "mvel"
when
login( userName == "" ||==null)
then
System.out.println("hello");
login lo = new login();
end
These are my files and my application runs without any error.Now I want to
show a message on my jsp page when the rule violates.can anybody provide me
a small piece of code.
Regards
Brajesh
--
View this message in context: http://drools.46999.n3.nabble.com/jsp-java-and-drl-file-tp4017955.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Trouble using java.util.List.size in constraints in 5.4.0.Final
by Alexis Brouard
Hi everyone,
I've tried to go from Drools 5.3.0.Final to 5.4.0.Final and some strange
errors appeared on constraints using the size of a list.
For instance, given the following object:
public class MyObject {
private List<String> param = new ArrayList<String>();
public MyObject() {
super();
}
public List<String> getParam() {
return param;
}
public void setParam(List<String> param) {
this.param = param;
}
}
This rule:
rule "Sample rule"
when
MyObject( param.size > 0 )
then
System.out.println( "Sample rule activated" );
end
Provokes the following error:
Unable to Analyse Expression param.size > 0:
[Error: Comparison operation requires compatible types. Found class
java.lang.String and class java.lang.Integer]
[Near : {... param.size > 0 ....}]
^ : [Rule name='Sample rule']
This worked very well in Drools 5.3.0.Final.
Is there some configuration specific to Drools 5.4.0.Final that I've missed
in the release notes?
Thanks in advance for your help.
Best,
Alexis
14 years
Programatically filled Enum not getting loaded
by Sandjaja, Dominik
I use Guvnor 5.4.0 with the following Assets:
Enum:
'Enums.Modules' : (new de.itm.util.DroolsEnumHelper()).loadModules()
DSL:
[when]Testmodule {module:ENUM:Enums.Modules} is just for testing={module} : Cylinder()
DroolsEnumHelper-Class:
public List<String> loadModules() {
List<String> values = new ArrayList<String>();
for (Module module : Module.values()) {
values.add(module.getModuleName() + "=" + module.getDisplayName());
}
return values;
}
When running the "Source->Validate" in the Enum-Editor, I see the method getting called (being connected to the JBoss for Debugging). But if I use the DSL rule in the guided editor, I can select the rule but the dropdown field stays grayed out. The loadModules() method isn't even called, no getting stuck in my breakpoint!
Anyone an idea why and how this happens? Am I doing something totally wrong?
Thanks
Dominik
...........................................................................
mit freundlichen Grüßen / kind regards
Dominik Sandjaja
Fon: +49 (0) 203 60878 183
Mobil +49 (0) 162 2624490
Fax: +49 (0) 203 60878 22
e-mail: dominik.sandjaja(a)it-motive.de
it-motive AG
Zum Walkmüller 10-12
47269 Duisburg
info(a)it-motive.de
http://www.it-motive.de <http://www.it-motive.de/>
..............................................................................
Vorsitzender des Aufsichtsrats: Dipl.-Ing. Klaus Straub
Vorstand: Horst-Dieter Deelmann (Vors.), Matthias Heming, Christoph Tim Klose
HRB 9207, Amtsgericht Duisburg
14 years