Need guide how to deploy rules
by Rahul Upadhyay
Hi
How can I add(deploy) rules in a web application( struts ) without using
BRMS in JBOSS server.
need sample example..
thanks in advance
regards
Rahul Upadhyay
17 years, 1 month
JBRMS persistence
by Mark Proctor
We use our own API which currently only has a jackrabbit impl - although
note that jackrabbit can have several backend types from disk, to memory
to database, where is even a hibernate persistence store. Creating a JCR
like implementation is a lot of work, we chose jackrabbit as it is
opensource and a standard and provides much of what we need out of the
box - why spend a month or three creating something that is like JCR but
is implemented with hibernate instead of just just using JCR? So in
reality our choice for JackRabbit is about time and leveraging what is
available, as there are no clear alternatives out there. That does not
mean we are against an alternative backend store, indeed Mic is mucking
around with a Scala implementation, we wrote against our own API exactly
so that we could replace JCR if we ever deemed it necessary. If someone
was to make a better backend for us, we would consider using it.
Mark
Michael Rhoden wrote:
> Couple questions about the JBRMS persistence layer. I have been trying to figure out how to upgrade and incorporate the new 4.03 code into my current app using 2.x and 3.x drools. After many months of off and on playing with 4.x I want to see if I have some things straight.
>
> 1) JBRMS is built atop Jackrabbit. It appears this is the only option for persistence. Is this correct?
> 2) It seems Jack Rabbit and the whole JCR standard, while nice I guess for coders, seems difficult to integrate with. All objects are stored as binaries, even in the db persistence manager and there is no way to access the rules except programmatically. Correct?
> 3) Assuming I'm on the right track with the above two items, and please don't take this the wrong way, I love you guys and what you are doing, why use Jackrabbit?
>
> It seems like a real bad idea to have an open system to store rules and then lock it away. I'm sure you guys have some good reasons but I'm having a real tough time and quite frankly am disappointed. From my perspective rules are one of the major assets of my company. I can't allow them to be locked up in a system. I must be able to access them from a jdbc source for backups, conversion, referencing, reporting, etc. The data however complex in structure must be transparent. Say I want to convert off Drools for another engine, or build around the JBRMS data structure to extend the app for proprietary purposes, or just want to access the rules in an indexed way to present them to power users to see the guts of a rule inside our application. Maybe you can do this now, I just haven't seen the light.
>
> Again I understand JBRMS is still quite new, and my hope Jackrabbit was just the quick and dirty way to get this deployed.
>
> 4) Are there any plans to have a straight jdbc persistence atop a hibernate (plug the ole JBoss way) backend?
>
> Not to leave you with just negative bits. Drools 4.x rocks and regardless of using the JBRMS we are looking at porting up to the latest version. The new frontend UI (coming soon) to the JBRMS looks nice too. Thanks for all the hard work.
>
> -Michael
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
17 years, 1 month
Globals in LHS of a rule?
by Michael Zimmermann
Hi there,
according to the online documentation globals are supported in the LHS
of a rule, yet requires a bit of care to use there.
But how do I use globals in the LHS? Is there any option to access a
globals variable directly like:
globals List myList
rule "SomeRule"
when
myList.size() == 2
then
...
Or can I have to use globals only in eval() statements?
cu, Michael
17 years, 1 month
inserting fact in subflow, availability to other flows?
by Eric Miles
I have a main flow that calls a subflow. In this subflow, I am
inserting a fact. In a rule in the main flow, it can not find this fact
in working memory. Is it possible to insert a fact in a subflow and
have it available to a parent flow?
Thanks!
17 years, 1 month
Rule firing problem - must be missing something obvious
by J Michael Dean
I am passing a glucose decision object with a value of 12, and have a
state object that starts out with its flag set false. The desired
behavior is that the value will be recognized as "extremeHypoglycemia"
by the first rule, and then the second rule will recommend giving a
glucose bolus.
When I pass both objects in without "true" to cause automatic
updating, then the first rule fires, the output is
false
Fired detect extreme hypoglycemia
true
and then the program stops. It does not fire the second rule.
When I add true to the insertion of these objects, then the program
recurses, and still never hits the second rule. Interestingly, the
output is
true
Fired detect extreme hypoglycemia
true
true
Fired detect extreme hypoglycemia
true
...
ETC.
rule "First rule: Detect extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision( serumGlucoseConcentration < 40 )
decisionState : GlucoseDecisionState(extremeHypoglycemia == false)
then
System.out.println("Fired detect extreme hypoglycemia");
System.out.println(decisionState.isExtremeHypoglycemia());
decisionState.setExtremeHypoglycemia(true);
decision.setRationaleText(decision.getRationaleText() +
"Extreme hypoglycemia (Current glucose is " +
decision.getSerumGlucoseConcentration() +" mg/dL).\n");
System.out.println(decisionState.isExtremeHypoglycemia());
update(decision);
end
rule "Second rule: Give glucose bolus for extreme hypoglycemia"
no-loop true
when
decision : GlucoseDecision()
decisionState : GlucoseDecisionState(extremeHypoglycemia == true )
then
System.out.println("Fired glucose bolus rule");
decisionState.setRecommendedGlucoseBolus(true);
decision.setRationaleText(decision.getRationaleText() +
"Glucose bolus recommended because of extreme hypoglycemia.\n");
end
17 years, 1 month
Best way to detect duplicate rule names?
by Jared Davis
Hi,
What is the best way to detect duplicate rule names in drl files? In my
application a duplicate rule name is an error.
There are multiple drl files loaded into one package. If the rule name is
duplicated across the files only the last rule is used. This behavior is clearly
documented.
The code below silently eats duplicated rules.
Reader sourceDrl = new InputStreamReader( new FileInputStream("r1.drl"));
Reader sourceDsl = new InputStreamReader( new FileInputStream("r.dsl"));
Reader sourceDrlTwo = new InputStreamReader( new FileInputStream("r2.drl"));
Reader sourceDslTwo = new InputStreamReader( new FileInputStream("r.dsl"));
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( sourceDrl, sourceDsl );
builder.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
System.out.println(builder.hasErrors()); // returns false
// A duplicate rule is not an error
Package pkg = builder.getPackage();
Is there a better alternative than loading each drl into a separate
PackageBuilder to track the individual rule counts in each drl file?
eg
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( sourceDrl, sourceDsl );
int ruleCountOne = builder.getPackage().getRules().length;
PackageBuilder builderTwo = new PackageBuilder();
builderTwo.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
int ruleCountTwo = builderTwo.getPackage().getRules().length;
// now re-compile file (reset readers as well...)
builder.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
if (builder.getPackage().getRules().length != (ruleCountOne + ruleCountTwo)) {
System.out.println("A duplicate exists - No clue what the name is");
// grep -i rule *.drl | sort | uniq -c
}
This does not detect a duplicate rule name in the same file - that would be even
better.
Regards,
Jared Davis
17 years, 1 month
RE:Problem Using Update
by Sikkandar Nawabjan
Hi,
I have rule like this
rule "Update Id"
dialect "mvel"
salience 100000
no-loop true
when
$add:Address(name=="india")
then
$add.setId("100");
update($add)
end
am getting the error org.drools.FactException: Update error: handle not found for object
and Address <mailto:Address@4b25933f> @4b25933f. Is it in the working memory?
what could be the problem? can't i use update??????
Thanks and Regs,
basha
17 years, 1 month
RE:update is not working properly
by Sikkandar Nawabjan
Hi,
This exception is not throwing very often. Occasionally i got this FactException . Is it because of another rule/Fact? i have the following rule also
rule "check created error"
dialect "mvel"
salience 100000
no-loop true
when
$add:Address(continent=="asia")
then
retract( $add)
can't a drl file contain both update and retract together? if both rules satisfy the facts what will happen for the handle?
Thanks and Regs,
Basha
Sikkandar Nawabjan wrote:
>
>
> Hi,
>
> I have rule like this
>
> rule "Update Id"
>
> dialect "mvel"
>
> salience 100000
>
> no-loop true
>
> when
>
> $add:Address(name=="india")
>
> then
>
> $add.setId("100");
>
> update($add)
>
> end
>
That should work, its a fairly trivial use case, so I'm very surprised
it doesn't.... If you are suare this isn't working for you, can you open
a jira with a minimal self contained test project showing the error.
> am getting the error org.drools.FactException: Update error: handle not found for object
>
17 years, 1 month
drools-ant task and decision tables
by Matija
Hi, does the drools-ant task know how to compile (.xls) decision
tables, or does it only compile .drl (and .brl, .xml etc.) files? I'm
having a bit of trouble getting it working, it keeps giving me the
"Unable to load dialect
'org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel'"
exception (anyone know what's up with that, as far as I know that
class is there along with all the required jars)?
I'm trying to determine if it's worth my time trying to resolve the
error (I can't use the ant task if it doesn't support decision
tables).
Regards,
M.
17 years, 1 month
BRMS Insurance Sample - Invalid Class Exception
by John Nader
I am seeing the same issue. My configuration is slightly different in
that I am using Drools 4.0.3 and JBoss 4.2.2GA with Java 5. I have been
searching very hard to find where these two different version of
AbstractParser are coming from. This class comes out of the MVEL. The
jar in the drools-jbrms is mvel14-1.2.10.jar. I only see this jar
within the deployment.
My thought is that a serialized version of the class is stored in a file
somewhere in the demo project or the BRMS itself, and that it is from an
older version mvel.
-J
--Original Message-
Folks,
Using BRMS 4.0.2 and examples 4.02 as downloaded from the 'official
release' site.
Working my way through the Drools Insurance Sample (on BRMS). I'm
deploying BRMS successfully on JBoss 4.2.1 with Java 1.6.0_02. I can
import the repository_export.xml ok and see the files. I leave this part
of the sample running as per the instructions.
When I go to the 2nd part of the example I have a problem running the
unit tests: within /drools-examples/drools-insurance I run: mvn clean
package. I get the error(1) at the bottom of this email. I do *not* get
the output as per the documentaiton. I skip the tests, build and deploy
the drools-insurance.war
When deploying the war I see the following error (2) in the JBoss logs .
However main drools insurance page loads ok as per the screenshot in the
documentation):
22:43:13,576 INFO [WebappClassLoader]
validateJarFile(C:\software\jboss-4-2-1\server\default\.\tmp\deploy\tmp2
6632drool
s-insurance-exp.war\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded.
See Servlet Spec 2.3, section 9.7.2. Offending class:
javax/servlet/Servlet.class
I enter some values in the web app (make sure there are no nulls) press
'continue' then get the same error (3)
22:48:55,294 ERROR [STDERR] java.io.InvalidClassException:
org.mvel.AbstractParser; local class incompatible: stream cla
ssdesc serialVersionUID = 256028721591955695, local class
serialVersionUID = -7464517220700761297
22:48:55,310 ERROR [STDERR] at
java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
As an aside , when I look for the latest BRMS , as mentioned in the docs
(http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules) - I get a
'Invalid File or Directory'
Is there anything I should try to resolve this?
Paul
RuleAgent(insuranceconfig) INFO (Thu Oct 18 22:37:44 BST 2007):
Configuring package provider : URLScanner monitoring URL
s:
http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acm
e.insurance.base/InsuranceDemo
RuleAgent(insuranceconfig) EXCEPTION (Thu Oct 18 22:37:45 BST 2007):
org.mvel.AbstractParser; local class incompatible:
stream classdesc serialVersionUID = 256028721591955695, local class
serialVersionUID = -7464517220700761297. Stack trace
should follow..io.ObjectStreamClass.initNonProxy(Unknown Source)
java.io.InvalidClassException: org.mvel.AbstractParser; local class
incompatible: stream classdesc serialVersionUID = 25
6028721591955695, local class serialVersionUID = -7464517220700761297
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)rce)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)urce)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)rce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)ource)
at java.io.ObjectInputStream.readObject(Unknown Source)own
Source)
at java.util.HashMap.readObject(Unknown Source)ce)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at java.lang.reflect.Method.invoke(Unknown Source)known Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)urce)
at java.io.ObjectInputStream.readObject(Unknown Source) Source)
at org.drools.rule.Package.readExternal(Package.java:194)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown
Source)java:54)
at java.io.ObjectInputStream.readObject0(Unknown Source)va:137)
at java.io.ObjectInputStream.readObject(Unknown Source)java:109)
at
org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:54)
at
org.drools.agent.URLScanner.readPackage(URLScanner.java:137)0)
at
org.drools.agent.URLScanner.getChangeSet(URLScanner.java:109))
at
org.drools.agent.URLScanner.loadPackageChanges(URLScanner.java:88)
at
org.drools.agent.RuleAgent.checkForChanges(RuleAgent.java:330)
at
org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:298)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:284)48)
at org.drools.agent.RuleAgent.init(RuleAgent.java:208)ava:216)
at
org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:176)romRuleAgent(
InsuranceSessionHelper.java:26)
at
org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:148)suranceSessio
nHelper.java:17)
at
org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:216)ntalInfoTest.
java:23)
at
org.acme.insurance.web.InsuranceSessionHelper.loadRuleBaseFromRuleAgent(
InsuranceSessionHelper.java:26)
at
org.acme.insurance.web.InsuranceSessionHelper.getSession(InsuranceSessio
nHelper.java:17)
at
org.acme.insurance.test.SupplementalInfoTest.setUp(SupplementalInfoTest.
java:23)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)tive Method)
at junit.framework.TestSuite.runTest(TestSuite.java:208)ource)
at junit.framework.TestSuite.run(TestSuite.java:203)nknown
Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source)estSet.java:210)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)uteTestSet(AbstractDirectoryTestSuite.java:135
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:2
10)DirectoryTestSuite.java:122)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSe
t(AbstractDirectoryTestSuite.java:135
) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Abstr
actDirectoryTestSuite.java:122)
at
org.apache.maven.surefire.Surefire.run(Surefire.java:129)ource)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
Source)Process(SurefireBooter.java:225)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)oter.java:747)
at java.lang.reflect.Method.invoke(Unknown Source)psed: 0.671
sec <<< FAILURE!
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Suref
ireBooter.java:225)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java
:747)
Tests run: 5, Failures: 0, Errors: 5, Skipped: 0, Time elapsed: 0.655
sec <<< FAILURE!
Running org.acme.insurance.test.DriverTestped: 0, Time elapsed: 0 sec
<<< FAILURE!
Tests run: 7, Failures: 0, Errors: 7, Skipped: 0, Time elapsed: 0.016
sec <<< FAILURE!
Running org.acme.insurance.test.DriverAdditionalInfoTestlapsed: 0.015
sec <<< FAILURE!
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.015
sec <<< FAILURE!
Running org.acme.insurance.test.InsuranceCalculateTest
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.016
sec <<< FAILURE!
17 years, 1 month