Hibernate
by Heyns, Juan
Hi,
I am getting the following error with 4.0.1, I didn't get this with
4.0.0... Has anything changed in the way Drools works with Hibernate.
Juan
15:24:52,281 ERROR LazyInitializationException:19 - failed to lazily
initialize a collection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a
collection, no session or session was closed
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationException(AbstractPersistentCollection.java:358)
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at
org.hibernate.collection.AbstractPersistentCollection.readElementExisten
ce(AbstractPersistentCollection.java:132)
at
org.hibernate.collection.PersistentSet.contains(PersistentSet.java:153)
at
org.drools.base.evaluators.ObjectFactory$ObjectContainsEvaluator.evaluat
eCachedLeft(ObjectFactory.java:481)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestrict
ion.java:72)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstrain
t.java:72)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaCo
nstraints.java:117)
at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:119)
at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTupl
e(CompositeTupleSinkAdapter.java:73)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode
.java:131)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleOb
jectSinkAdapter.java:20)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:160)
at org.drools.reteoo.Rete.assertObject(Rete.java:176)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:854)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:826)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:60)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:54)
at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0.consequence(Rule_Stope_Drilling_work_i
s_evaluated_based_on_the_holes_drilled_and_blasts_0.java:35)
at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0ConsequenceInvoker.evaluate(Rule_Stope_
Drilling_work_is_evaluated_based_on_the_holes_drilled_and_blasts_0Conseq
uenceInvoker.java:22)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:434)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:396)
at
com.lonmin.bns.domain.rules.RulesEngine.calculateStopeDrillingBonus(Rule
sEngine.java:54)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processDetail(Sto
peDrillingCardPersister.java:371)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processCard(Stope
DrillingCardPersister.java:276)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.process(StopeDril
lingCardPersister.java:69)
at
com.lonmin.bns.domain.model.ValueObjectPersister.persist(ValueObjectPers
ister.java:38)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersisterTest.testEditStope
DrillingCard(StopeDrillingCardPersisterTest.java:182)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:392)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:276)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:167)
org.hibernate.LazyInitializationException: failed to lazily initialize a
collection, no session or session was closed
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationException(AbstractPersistentCollection.java:358)
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ
ationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at
org.hibernate.collection.AbstractPersistentCollection.readElementExisten
ce(AbstractPersistentCollection.java:132)
at
org.hibernate.collection.PersistentSet.contains(PersistentSet.java:153)
at
org.drools.base.evaluators.ObjectFactory$ObjectContainsEvaluator.evaluat
eCachedLeft(ObjectFactory.java:481)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestrict
ion.java:72)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstrain
t.java:72)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaCo
nstraints.java:117)
at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:119)
at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTupl
e(CompositeTupleSinkAdapter.java:73)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode
.java:131)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleOb
jectSinkAdapter.java:20)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:160)
at org.drools.reteoo.Rete.assertObject(Rete.java:176)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:
70)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:854)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.jav
a:826)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:60)
at
org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.jav
a:54)
at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0.consequence(Rule_Stope_Drilling_work_i
s_evaluated_based_on_the_holes_drilled_and_blasts_0.java:35)
at
com.lonmin.bns.domain.rules.Rule_Stope_Drilling_work_is_evaluated_based_
on_the_holes_drilled_and_blasts_0ConsequenceInvoker.evaluate(Rule_Stope_
Drilling_work_is_evaluated_based_on_the_holes_drilled_and_blasts_0Conseq
uenceInvoker.java:22)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:434)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:396)
at
com.lonmin.bns.domain.rules.RulesEngine.calculateStopeDrillingBonus(Rule
sEngine.java:54)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processDetail(Sto
peDrillingCardPersister.java:371)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.processCard(Stope
DrillingCardPersister.java:276)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersister.process(StopeDril
lingCardPersister.java:69)
at
com.lonmin.bns.domain.model.ValueObjectPersister.persist(ValueObjectPers
ister.java:38)
at
com.lonmin.bns.domain.model.StopeDrillingCardPersisterTest.testEditStope
DrillingCard(StopeDrillingCardPersisterTest.java:182)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:392)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:276)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:167)
"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee shall
not be legally binding on Lonplats and Lonplats shall incur no liability of
any nature whatsoever, directly or indirectly, arising from such act on the
part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"
16 years, 11 months
ClassNotFound exception running brms example (newbie)
by Martin Fuzzey
Hi,
I am trying to run the insurance example with the brms
after replacing the client mvel jar with the one used by the brms web
app as mentionned on this list I get this exeception (full stacktrace below)
java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.mvel.MVELDialect$ModifyInterceptor
adding the drools-compiler-4.0.1.jar to the client classpath fixes this
but I thought the rules were supposed to be compiled by the brms. Indeed
the documentation says :
The rule agent is a component which is embedded in the core runtime of
the rules engine. To use this, you don't need any extra components. In
fact, if you are using the BRMS, your application should only need to
include the drools-core.jar in its classpath, and no other rules
specific dependencies.
so am I misunderstanding something or is this a bug?
Thanks,
Martin Fuzzey
RuleAgent(insuranceconfig) INFO (Sun Sep 30 14:02:33 CEST 2007):
Configuring with newInstance=true, secondsToRefresh=30
RuleAgent(insuranceconfig) INFO (Sun Sep 30 14:02:33 CEST 2007):
Configuring package provider : URLScanner monitoring URLs:
http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acme...
with local cache dir of /home/martin/tmp
RuleAgent(insuranceconfig) EXCEPTION (Sun Sep 30 14:02:34 CEST 2007):
org.drools.rule.builder.dialect.mvel.MVELDialect$ModifyInterceptor.
Stack trace should follow.
java.lang.ClassNotFoundException:
org.drools.rule.builder.dialect.mvel.MVELDialect$ModifyInterceptor
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at
org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:74)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1029)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1029)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
rImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.drools.rule.Package.readExternal(Package.java:189)
at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at
org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:54)
at org.drools.agent.URLScanner.readPackage(URLScanner.java:137)
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:327)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:295)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:281)
at org.drools.agent.RuleAgent.init(RuleAgent.java:205)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:173)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:145)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:213)
at
org.acme.insurance.launcher.InsuranceBusiness.loadRuleBase(InsuranceBusiness.java:26)
at
org.acme.insurance.launcher.InsuranceBusiness.executeExample(InsuranceBusiness.java:14)
at org.acme.insurance.launcher.MainClass.main(MainClass.java:13)
RuleAgent(insuranceconfig) WARNING (Sun Sep 30 14:02:35 CEST 2007): Was
unable to load a class when loading a package. Perhaps it is missing
from this appl
16 years, 11 months
Problems archiving and restoring packages in the BRMS
by Shahad Ahmed
I've come across a few serious usability problems whilst using the import
and archiving packages functionality in the BRMS. However, before raising a
JIRA, I thought I'd ask the community if these are expected behaviours, or
legitimate bugs.
1. Archiving a package only removes the package definition – all rules etc
in the package are not archived. Is this the expected behaviour? As a naive
user I would have expected the package and all its rules etc to be archived.
2. The archived package definition does not show up in the list of archived
assets under the Admin/Manage Archived Assets option. Is the list of
archived packages available elsewhere, and if so can you restore an archived
package again?
3. I archived a package in the BRMS – which removed the package from the
listed packages in the BRMS. I then tried to create a new package with the
same name as the archived (i.e. removed) package using the "Import package
from drl" option. The new drl package had rules with different names from
the original rules in the archived package. However, the new package was not
created from the drl (the new package name does not show up in the list of
packages), although the new rules in the drl where imported. If you try to
recreate this, be aware that it wont be obvious the new rules have imported
as their containing package is not created – and as the imported rules from
a drl have no category they do not show up in the list of rules, unless you
search for them by name.
Am I right in thinking that the problem with archiving a package, and then
failing to recreate the package with the same name using the import
mechanism is a bug, or is there something subtle I'm missing with this
behaviour?
Regards
Shahad
16 years, 11 months
Need clarification when using maps
by Jeffery Shutt
There has to be something I do not understand about using rules.
Take this simple class and rules and I don't understand the output.
First, when the rule constructor is executed it appears as though only the
value 1 was put into the map, then it runs rule test1 and then it sees only
values 2 and 3.
Secondly, look at rule test2 right now the RHS displays true, BUT if you
comment out the eval(true) and uncomment either of the evals you get a
nullpointer at runtime. I do not understand why there is a null pointer. Any
insight would be wonderful, I have been banging my head against this for a
bit and it's probably something stupid.
Thanks!
---------------------------------
package test.map;
import java.util.HashMap;
import java.util.Map;
public class Test
{
public Test()
{
values = new HashMap<String, Object>();
}
private Map<String, Object> values;
public Map<String, Object> getValues()
{
return values;
}
public void setValues(Map<String, Object> values)
{
this.values = values;
}
}
-----------------------------------------
package test.map
import java.math.BigDecimal;
import java.util.Map;
rule "Constructor"
no-loop true
when
eval(true);
$t : Test(values:values)
then
drools.setFocus("test2");
drools.setFocus("test1");
values.put("one", new BigDecimal("1"));
addValue($t, "two", new BigDecimal("2"));
$t.getValues().put("three", new BigDecimal("3"));
update($t);
System.out.println("in constructor");
System.out.println(values);
System.out.println();
end
rule "test1"
no-loop true
agenda-group "test1"
when
eval(true);
$t : Test(values:values)
then
System.out.println("in test1");
System.out.println(values);
System.out.println();
end
rule "test2"
no-loop true
agenda-group "test2"
when
eval(true);
$t : Test(values:values)
//eval(((BigDecimal)values.get("two")).equals(new BigDecimal("2")));
//eval(((BigDecimal)$t.getValues().get("two")).equals(new
BigDecimal("2")));
then
System.out.println(((BigDecimal)$t.getValues().get("two")).equals(new
BigDecimal("2")));
end
function void addValue(Test t, String key, BigDecimal value)
{
t.getValues().put(key, value);
}
---------------------------------------
This is a simple class to start it up.
---------------------------------------
package test.map;
import java.io.InputStreamReader;
import java.io.Reader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
public class Mainclass
{
public static void main(String[] args)
{
try
{
//load up the rulebase
RuleBase ruleBase = readRule();
WorkingMemory workingMemory =
ruleBase.newStatefulSession();
Test test = new Test();
workingMemory.insert(test);
workingMemory.fireAllRules();
}
catch (Throwable t)
{
t.printStackTrace();
}
}
/**
* Please note that this is the "low level" rule assembly API.
*/
private static RuleBase readRule() throws Exception
{
Reader source = new
InputStreamReader(Mainclass.class.getResourceAsStream("/Nulltest.drl"));
System.setProperty("drools.compiler", "JANINO");
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( source );
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
}
Jeff Shutt
Software Developer
SOS Staffing Services
(801) 924-0429
shuttj(a)sosstaffing.com
16 years, 11 months
accumulate funtion in xml
by Isabelle Hupont
Hi!
I want to program the following drl rule in xml:
rule "average calculation"
no-loop true
when
_i : Instance()
_average : Double()
from accumulate(accInst: Instance(),
average(accInst.value("tend")))
eval(_average < 20000)
then
_i.setValue("tend",2000);
end
For it, I have implemented the following xml file:
<?xml version="1.0" encoding="UTF-8"?>
<package name="org.prophet.fuzzy" xmlns="http://drools.org/drools-4.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
<import name="weka.core.*"/>
<import name="org.prophet.gui.docking.*"/>
<import name="org.prophet.persistence.*"/>
<import name="org.prophet.persistence.hibernate.*"/>
<import name="org.prophet.rules.*"/>
<import name="org.prophet.*"/>
<rule name="Rule1">
<rule-attribute name="no-loop" value="true"/>
<lhs>
<pattern identifier="_i" object-type="Instance"/>
<pattern identifier="_average" object-type="Double">
<from>
<accumulate>
<pattern identifier="accInst"
object-type="Instance"/>
<external-function evaluator="average"
expression="accInst.value("tend")"/>
</accumulate>
</from>
</pattern>
<eval>_average < 20000.0</eval>
</lhs>
<rhs>
_i.setValue("tend", 2000.0); manageRuleFired("Rule1", null, _i);
modify(_i);</rhs>
</rule>
</package>
And I have the following error when reading the rule package:
org.drools.rule.InvalidRulePackage: Rule Compilation error _average cannot
be resolved _i cannot be resolved _i cannot be resolved _i__Handle__ cannot
be resolved _i cannot be resolved
I also have tried to replace the xml identifier <pattern> by <column> with
no result. Can you help me, please?
--
View this message in context: http://www.nabble.com/accumulate-funtion-in-xml-tf4526879.html#a12916380
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 11 months
Please help
by Bhattacharya, Sougata
Hi All,
I am using drool to validate my business objects. I have a Business
object like this
LineItem
String ID
String parentId
I get 5 LineItems in a row and each line item has ID and a Parent ID, I
will have to check
if(parented of Any LineItem ! = ID of any LineITem)
I have to show an exception,
Please help me to solve this
Cheers
Su
This message contains information that may be privileged or confidential
and is the property of the Capgemini Group. It is intended only for the
person to whom it is addressed. If you are not the intended recipient,
you are not authorized to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all
copies of this message.
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
16 years, 11 months
Firing of specific rules
by prateek.katiyar@wipro.com
Hi
I am using Drools 4.0.
First time I want to fire some specific rules from my rule file(in .xml format) and then other rules for the second time.
I have defined agenda-group attribute for the rules as follows:
<rule-attribute name="agenda-group" value="Check-rfq"/>
how can I execute specific rules using agenda group or is there any other options are available.
When I had gone through Drools documentation ,they mentioned Listener api can be used to execute specific rules but I did not find enough information on Listener.
Please let me know how can I implement Listener api to execute specific rules.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
16 years, 11 months
Classpath and jar issue
by Krishnan
hi all,
In my application, I use simple drl file based rules and it is not a J2EE
application. Based on the dependencies
documentation
http://anonsvn.labs.jboss.com/labs/jbossrules/tags/4.0.1.14754GA/README_D...
, it seems I am in the compiler option
The only jars I am including are as follows :-
drools-compiler-4.0.0.jar
drools-core-4.0.0.jar
drools-decisiontables-4.0.0.jar
drools-jsr94-4.0.0.jar
antlr-runtime-3.0.jar
mvel14-1.2rc1.jar
core-3.2.3.v_686_R32x.jar [Can anyone explain why I need this, the
documentation seems like this is optional, but when I
don't specify this, it does not work ?.]
I also tried not including the core but including the janino library and
specifying the janino compiler at run time and that also
expects the core to be included. Any help is appreciated.
TIA,
Krishnan.
--
Sivaramakrishna Iyer Krishnan (Anand)
Never assume the obvious is true.
- William Safire
16 years, 11 months
licensing text
by Krishnan
hi,
I am trying to use drools 4.0 for our project and understand the licensing
agreement for drools. Drools
uses Apache license where as some of the dependant libraries use New BSD and
other type of licenses.
Since I am not a lawyer, does anybody have any idea of any implications on
any problems related to
the licenses ?.
Drools use the following libraries
antlr-runtime-3.0.jar
core-3.2.3.v_686_R32x.jar
janino-2.5.7.jar
jsr94-1.1.jar
jxl-2.4.2.jar
mvel14-1.2rc1.jar
xercesImpl-2.4.0.jar
xml-apis-1.0.b2.jar
xpp3-1.1.3.4.O.jar
xstream-1.1.3.jar
(a) Do you guys have the licensing agreement for each of these jars ?
(b) Also, I tried searching for the websites using their name but some of
them I am not able to find. IF you
have the website information for these jars, that will help.
(c) Has anybody run into any particular licensing issue problem with Drools
?.
Any help is appreciated.
Thanks,
Krishnan.
--
Sivaramakrishna Iyer Krishnan (Anand)
Never assume the obvious is true.
- William Safire
16 years, 11 months
BRMS class cast exception
by Wojtek Kedzior
Hello,
Im having trouble with the BRMS front end throwing an:
Exception in thread "main" java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.List
at org.drools.rule.Package.readExternal(Package.java:172)
This is what I have set up:
jbossweb-1.0.1.GA
drools-4.0.1-brms
Java version 1.6.0 - VM 1.6.0-b105
mvel jar file:
mvel14-1.2rc4rv908 (taken from the jbossweb lib)
This is the class, which i put into a .jar, which in turn I import into the front end:
package data;
import java.io.Serializable;
public class ExceptionType implements Serializable{
private String customerType = "";
private String exceptionType = "";
public ExceptionType(){}
public ExceptionType(String customerType, String exceptionType)
{
this.exceptionType = exceptionType;
this.customerType = customerType;
}
public void setExceptionType(String exceptionType) {
this.exceptionType = exceptionType;
}
public String getExceptionType() {
return exceptionType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
public String getCustomerType() {
return customerType;
}
}
And here is the starting point:
package data;
import java.util.Properties;
import org.drools.RuleBase;
import data.ExceptionType;
import org.drools.StatefulSession;
import org.drools.agent.RuleAgent;
public class Runner {
public Runner()
{
ExceptionType e = new ExceptionType("das", "32432");
e.setExceptionType("system failure");
Properties prop = new Properties();
prop.setProperty("newInstance", "true");
prop.setProperty("url","http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/defaultP...");
prop.setProperty("poll", "30");
RuleAgent agent = RuleAgent.newRuleAgent(prop); //error occurs on this line.
RuleBase rb = agent.getRuleBase();
StatefulSession session = rb.newStatefulSession();
session.insert(e);
session.fireAllRules();
}
/**
* @param args
*/
public static void main(String[] args)
{
new Runner();
}
}
I have specified a package import in the packge in the front end:
import data.ExceptionType
Validation of the .jar file and build of the package seem to work fine.
Here is the complete stack trace:
RuleAgent(default) INFO (Fri Sep 28 21:57:54 NZST 2007): Configuring with newInstance=true, secondsToRefresh=30
RuleAgent(default) INFO (Fri Sep 28 21:57:54 NZST 2007): Configuring package provider : URLScanner monitoring URLs: http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/defaultP...
Exception in thread "main" java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.List
at org.drools.rule.Package.readExternal(Package.java:172)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.drools.agent.HttpClientImpl.fetchPackage(HttpClientImpl.java:54)
at org.drools.agent.URLScanner.readPackage(URLScanner.java:137)
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:297)
at org.drools.agent.RuleAgent.refreshRuleBase(RuleAgent.java:265)
at org.drools.agent.RuleAgent.configure(RuleAgent.java:251)
at org.drools.agent.RuleAgent.init(RuleAgent.java:183)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:140)
at data.Runner.<init>(Runner.java:25)
at data.Runner.main(Runner.java:37)
Any help would be appreciated.
Thanks,
Wojtek Kedzior
First Data Utilities
Auckland, New Zealand
Software Engineering
16 years, 11 months