Re: [rules-users] Accessing maps (hashmaps) keys and values in rules

2007-10-31 Thread Shaz Tumulak

Hi,

I can't seem to make this syntax work in Drools 4.0.2. Pls. see my sample
code below.

class MyClass {
String id;
String name;

MyClass(String id, String name){
this.id = id;
this.name = name;
}
:
getter, setter methods
:
}

MyClass obj = new MyClass("1"", "name");

TreeMap mapOfObj = new TreeMap();
mapOfObj.put("keyOfObj", obj);


DRL file
---

global java.util.TreeMap mapOfObj;

rule chkobj
when
obj : MyClass(mapOfObj["keyOfObj"].id == "1");
eval(obj.getName() == "name");


I'm getting this error: org.drools.RuntimeDroolsException:
java.lang.NullPointerException
at
org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:76)

Is my syntax correct and has someone used this in 4.0.2 or should I move on
to Drools 4.0.3? Thanks in advance.

Regards,

shaz


Edson Tirelli-3 wrote:
> 
>Denis,
> 
>If you are using latest build from trunk (I'm not sure it already works
> in MR3), you can use a simplified MVEL syntax:
> 
> when
> Person( address["business"].phone == "" )
> then
> ...
> end
> 
>Although, the above will be converted into an inline-eval. Not as bad
> as
> a top level eval, but still more costly then using regular fields.
> 
>[]s
>Edson
> 
> 2007/7/19, Ryan, Dennis (Dennis) <[EMAIL PROTECTED]>:
>>
>>  We are using Maps (HashMaps) in our rules and the only way we have found
>> to access keys and values in the Map in the "when" clauses is thru use on
>> eval() which I know is a big no-no by rules purists. Is there a better
>> way,
>> maybe some shorthand I'm not familiar with to deal with Maps in the when
>> clause?
>>
>>
>>
>> Thanks,
>>
>> Dennis
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
> 
> 
> -- 
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   JBoss, a division of Red Hat @ www.jboss.com
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
[EMAIL PROTECTED]
-- 
View this message in context: 
http://www.nabble.com/Accessing-maps-%28hashmaps%29-keys-and-values-in-rules-tf4112197.html#a13524477
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Problem with DSL in Drools 4.0.3

2007-10-31 Thread tansey

I finally figured out the problem.  I didn't know that you couldn't mix mvel
and a DSL in a rule.  So by following those 8 steps, essentially that's what
was happening.





tansey wrote:
> 
> I've tried this in clean installs of different versions of eclipse and
> it's still not recognizing it, so I must be missing a step.  The following
> is what I did:
> 
> 1. File -> New -> Drools -> Rule Project -> Finish
> 2. Added new Domail Specific Language named mylang.dsl to the source
> folder src/main/rules
> 3. Removed all of the template rules except the Log one
> 4. Added "expander mylang.dsl" after import statement in Sample.drl
> 5. Uncommented line 45 (Reader dsl = ...) in DroolsTest.java
> 6. Commented out line 54: builder.addPackageFromDrl( source );
> 7. Uncommented line 57: builder.addPackageFromDrl( source, dsl );
> 8. Right-clicked on DroolsTest.java -> Run As -> Java Application
> 
> The program throws an exception saying it is unable to expand several
> lines. Did I do something wrong? If not, do these steps work for anyone
> else?
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-with-DSL-in-Drools-4.0.3-tf4722439.html#a13523090
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Using java.util.List in rules

2007-10-31 Thread Rahul Phadnis
Do you have an import statement for importing
TipoCaracteristica?

I see you are already using  TipoMolde.CABELO which I
assume is another public static variable in the
TipoMolde class.

If none of these work can you post your drl file?

Rahul

--- Anderson Pazza Mello <[EMAIL PROTECTED]> wrote:

> Yes I'm Brazilian
> I need to improve my english I now hehehe
> 
> About the problem... I solved it.
> 
> But now I'm getting this error when I use a static
> property in the rules:
> 
> Exception in thread "AWT-EventQueue-0"
> org.drools.RuntimeDroolsException:
> Exception executing predicate
> [EMAIL PROTECTED]
> at
> org.drools.rule.PredicateConstraint.isAllowed(
> PredicateConstraint.java:197)
> at
>
org.drools.reteoo.FromNode.assertTuple(FromNode.java:70)
> at
>
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:29)
> at
> org.drools.reteoo.EvalConditionNode.assertTuple(
> EvalConditionNode.java:150)
> at
>
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:20)
> at
>
org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> at
>
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:20)
> at
>
org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> at
>
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:20)
> at
>
org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> .
> .
> .
> 
> Caused by: org.mvel.PropertyAccessException: unable
> to resolve property:
> unable to resolve token:
> TipoCaracteristica.CABELO_TOTALMENTE_CALVO
> at
> org.mvel.ast.PropertyASTNode.initializePropertyNode(
> PropertyASTNode.java:86)
> at
>
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(
> PropertyASTNode.java:23)
> at
>
org.mvel.ast.BinaryOperation.getReducedValueAccelerated(
> BinaryOperation.java:20)
> at
> org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
> at
>
org.mvel.CompiledExpression.getValue(CompiledExpression.java:99)
> at
> org.mvel.MVEL.executeExpression(MVEL.java:219)
> at
>
org.drools.base.mvel.MVELPredicateExpression.evaluate(
> MVELPredicateExpression.java:36)
> at
> org.drools.rule.PredicateConstraint.isAllowed(
> PredicateConstraint.java:191)
> ... 44 more
> 
> Example:
> 
> Property :
> public class TipoCaracteristica implements
> java.io.Serializable{
> .
> .
> 
> public static int CABELO_TOTALMENTE_CALVO = 37;
> .
> .
> .
> }
> 
> rule:
> 
> rule "CABELO_TOTALMENTE_CALVO resposta nao / Chama
> Tipo de Cabelo"
> salience 90
> when
> e : Especialista(perguntado == false)
> Especialista( $retrato : retratoUser)
> Retrato($lstCaracRetrato : lstCarac) from
> $retrato
> Retrato($lstMolde : lstMolde) from $retrato
> Molde(tipoMolde.codTipMolde ==
> TipoMolde.CABELO && $lstCaracMolde:
> lstCarac) from $lstMolde
> //CABELO_TIPO = 10
> eval(naoPerguntou($lstCaracMolde, 10))
> //CABELO_TOTALMENTE_CALVO = 37 e
> RESPOSTA_SIM = 154
> Caracteristica(tipCarac.codTipCarac ==
> TipoCaracteristica.CABELO_TOTALMENTE_CALVO &&
> valor.codValor == 154) from
> $lstCaracMolde
> then
>
>
buscarMontarPergunta(e,Pergunta.CABELO_TIPO,Especialista.CABELO);
> e.perguntado = true;
> update(e);
> end
> 
> I get some statics properties like
> "TipoMolde.CABELO" without errors, but I
> can't use the properties from this class
> (TipoCaracteristica). Did you know
> why?
> If I use de value like this "valor.codValor == 154",
> I have no problem.
> 
> 2007/10/29, Edson Tirelli <[EMAIL PROTECTED]>:
> >
> >
> > Anderson,
> >
> > What is the error? Can you provide a self
> contained example?
> > Using the "from CE" as showed before works.
> >
> > BTW, are you Brazilian? Your name sounds like
> a Brazilian name.
> >
> >  []s
> >  Edson
> >
> > 2007/10/27, Anderson Pazza Mello
> <[EMAIL PROTECTED]>:
> > >
> > > How can I test all elements of the list?
> > > Can I need to use something like "for (int
> i.)"?
> > >
> > > I'm trying to do that but it is not working...
> > >
> > > "Caracteristica( codCarac != 0 ) from
> $caracList"
> > >
> > >
> > >
> > > My test:
> > >
> > > e : Especialista (perguntado == false)
> > > Especialista( $moldeList :
> retratoUser.lstMolde )
> > > Molde( tipoMolde == TipoMolde.CABELO)
> from $moldeList
> > >
> > >
> > > When  the property  "tipoMolde ==
> TipoMolde.CABELO" the rule must to be
> > > fired. The List $moldeList has 5 elements.
> > >
> > > any idea?
> > >
> > >
> > > 2007/10/3, Edson Tirelli < [EMAIL PROTECTED]>:
> > > >
> > > >   Use the "from" CE:
> > > >
> > > > rule "This rule will fire once for each
> Caracteristica whose codCarac
> > > > is != 0"
> > > > when
> > > > Especialista( $caracList :
> retratoUser.lstCarac )
> > > > Caracteristica( codCarac != 0 ) from
> $caracList
> > > 

RE: [rules-users] Problem with DSL in Drools 4.0.3

2007-10-31 Thread tansey

I've tried this in clean installs of different versions of eclipse and it's
still not recognizing it, so I must be missing a step.  The following is
what I did:

1. File -> New -> Drools -> Rule Project -> Finish
2. Added new Domail Specific Language named mylang.dsl to the source folder
src/main/rules
3. Removed all of the template rules except the Log one
4. Added "expander mylang.dsl" after import statement in Sample.drl
5. Uncommented line 45 (Reader dsl = ...) in DroolsTest.java
6. Commented out line 54: builder.addPackageFromDrl( source );
7. Uncommented line 57: builder.addPackageFromDrl( source, dsl );
8. Right-clicked on DroolsTest.java -> Run As -> Java Application

The program throws an exception saying it is unable to expand several lines.
Did I do something wrong? If not, do these steps work for anyone else?
-- 
View this message in context: 
http://www.nabble.com/Problem-with-DSL-in-Drools-4.0.3-tf4722439.html#a13521507
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Problem with removePackage()

2007-10-31 Thread Edson Tirelli
   Can you try 4.0.3? There was some fix for package management included in
4.0.2 if I'm not mistaken...

   []s
   Edson

2007/10/31, igor_b <[EMAIL PROTECTED]>:
>
>
> Hi,
>
> I'm using drools 4.0.1. I'm first adding one package to my RuleBase
> object,
> and everything works just fine:
>
> ...
> builder.addPackageFromDrl(new InputStreamReader(resource.getInputStream
> ()));
>
> if(ruleBase == null) {
> ruleBase = RuleBaseFactory.newRuleBase();
> }
> ruleBase.addPackage(builder.getPackage());
>
>
> But after some time i need to refresh my rules, so i'm using following
> code
> to remove previous package:
>
> ruleBase.removePackage("org.sample.mypackage");
>
> and i'm getting the following error:
>
> java.lang.NullPointerException
> at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java
> :222)
> at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java
> :272)
> at
> org.drools.common.AbstractRuleBase.removePackage(AbstractRuleBase.java
> :460)
> at
> com.diosphere.diomedia.common.drools.impl.RulesServiceImpl.refresh(
> RulesServiceImpl.java:121)
> at
> com.diosphere.diomedia.service.impl.PromotionManagerImpl.refreshDRLs(
> PromotionManagerImpl.java:39)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> :39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java
> :170)
> at
> uk.ltd.getahead.dwr.impl.DefaultProcessor.doExec(DefaultProcessor.java
> :552)
> at
> uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:88)
> at uk.ltd.getahead.dwr.DWRServlet.doPost(DWRServlet.java:178)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:290)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:206)
> at
> com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(
> PageFilter.java:118)
> at
> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(
> PageFilter.java:52)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:206)
> at
> net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java
> :167)
> at
> net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(
> FilterToBeanProxy.java:120)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:230)
> at
> org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:175)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> :128)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> :104)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:109)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
> :261)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
> Http11Protocol.java:581)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
> JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:619)
>
> Does anyone have a clue what might be the problem, and how to fix it?
> Kind regards!
> --
> View this message in context:
> http://www.nabble.com/Problem-with-removePackage%28%29-tf4727072.html#a13516014
> Sent from the drools - user mailing list archive at Nabble.com.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Initialize Global

2007-10-31 Thread Joshua Undesser

I am doing something similar and having some issues.   I am physically
calling setGlobal, but it doesn't seem to be getting setexample

global String USER_NAME;

rule "Initialize Globals"
salience 100
when
eval(USRE_NAME == null )
then
String name = "Josh";
drools.getWorkingMemory().setGlobal("USER_NAME", name);
System.out.println("Local Name : " + name);
System.out.println("Global Name : " + USER_NAME);
end


This produces

Josh
Null

Not sure I fully follow what is happening.I am calling setGlobal, but
the value does not appear to get set, thus the null in the last output
statement.

Also any other rule I have set up that utilizes the USER_NAME global won't
fire, ie


rule "Second Rule to Fire"

when
eval(USER_NAME != null)
then
System.out.println("Fired Second Rule);
end

This rule never fires.

Can anyone explain this?  And just to clarify, yes, USER_NAME is going to be
immutable once set.

Thanks in advance!

Joshua





Kris Verlaenen wrote:
> 
> You can create a rule that initializes your global, preferrably with a
> high 
> salience so it gets executed first:
> 
> rule "InitializeGlobal" salience 100
>   when
>   then
> ArrayList objectList = new ArrayList();
> objectList.add("1");
> objectList.add("2");
> drools.getWorkingMemory().setGlobal("objectList", objectList);
> end
> 
> Kris
> 
> - Original Message - 
> From: "drools_user" <[EMAIL PROTECTED]>
> To: 
> Sent: Wednesday, October 24, 2007 7:35 PM
> Subject: [rules-users] Initialize Global
> 
> 
>>
>> How do I initialize a global fact in the drl file?  I want use the JSR94 
>> API
>> and avoid using the Drools API inside the Java code.  I would like to 
>> access
>> the same variable every execution of a stateful session without having to
>> reinstantiate the variable after each execution?
>>
>> Basically I want to define a global like this:
>> # Define global variable
>> global List objectList ;
>>
>> # Part that does not work
>> objectList = new ArrayList() ;
>> objectList.add("1");
>> objectList.add("2");
>>
>>
>> Thanks
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Initialize-Global-tf4685186.html#a13388685
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users 
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Initialize-Global-tf4685186.html#a13517718
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Problem with removePackage()

2007-10-31 Thread igor_b

Hi, 

I'm using drools 4.0.1. I'm first adding one package to my RuleBase object,
and everything works just fine: 

...
builder.addPackageFromDrl(new InputStreamReader(resource.getInputStream()));

if(ruleBase == null) {
ruleBase = RuleBaseFactory.newRuleBase();
}
ruleBase.addPackage(builder.getPackage());


But after some time i need to refresh my rules, so i'm using following code
to remove previous package:

ruleBase.removePackage("org.sample.mypackage");

and i'm getting the following error:

java.lang.NullPointerException
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:222)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:272)
at
org.drools.common.AbstractRuleBase.removePackage(AbstractRuleBase.java:460)
at
com.diosphere.diomedia.common.drools.impl.RulesServiceImpl.refresh(RulesServiceImpl.java:121)
at
com.diosphere.diomedia.service.impl.PromotionManagerImpl.refreshDRLs(PromotionManagerImpl.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:170)
at
uk.ltd.getahead.dwr.impl.DefaultProcessor.doExec(DefaultProcessor.java:552)
at
uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:88)
at uk.ltd.getahead.dwr.DWRServlet.doPost(DWRServlet.java:178)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
at
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:167)
at
net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

Does anyone have a clue what might be the problem, and how to fix it?
Kind regards!
-- 
View this message in context: 
http://www.nabble.com/Problem-with-removePackage%28%29-tf4727072.html#a13516014
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] RE: JavaConsequenceBuilder.buildNullPointerException

2007-10-31 Thread Edson Tirelli
   Already did. Will be included in the next release:

http://jira.jboss.com/jira/browse/JBRULES-1311

[]s
Edson

2007/10/31, Michael Fuller <[EMAIL PROTECTED]>:
>
>  Thank you so very much. Yes, changing the parse to handle this would be
> very helpful.
>
>
>  --
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Edson Tirelli
> *Sent:* Wednesday, October 31, 2007 12:32 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] RE:
> JavaConsequenceBuilder.buildNullPointerException
>
>
>
>
>Michael,
>
>The problem is you missed the "" on:
>
> $result.addPassedRule(leaders in same location);
>
>
> I will fix the parser code to not throw NPE for this anymore.
>
> Thanks,
>   Edson
>
> 2007/10/31, Michael Fuller <[EMAIL PROTECTED]>:
>
> Sure. Thanks
>
>
>
> package validActions;
>
> import myPackage.domain.leader.LeaderImpl;
>
> import myPackage.domain.location.LocationImpl;
>
> import myPackage.domain.leader.LeaderTypeImpl;
>
> import myPackage.rivoli.service.rules.RuleResult;
>
>
>
> rule "leaders in same location"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leaders in same
> location")
>
> $loc : LocationImpl()
>
> $leaderName : String()
>
> $leader1 : LeaderImpl(name == $leaderName, location == $loc)
>
> $leader2 : LeaderImpl(name != $leaderName, this != $leader1, location
> == $loc)
>
> then
>
> $result.addPassedRule(leaders in same location);
>
> update($result);
>
> end
>
>
>
> rule "leaders king and heir"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leaders king and heir")
>
> $leaderName : String()
>
> $king : LeaderTypeImpl(name == "King")
>
> $heir : LeaderTypeImpl(name == "Heir")
>
> $leader1 : LeaderImpl(name == $leaderName, leaderType == $king)
>
> $leader2 : LeaderImpl(name != $leaderName, this != $leader1,
> leaderType == $heir)
>
> then
>
> $result.addPassedRule("leaders king and heir");
>
> update($result);
>
> end
>
>
>
> rule "leader in capital"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leader in capital")
>
> $loc : LocationImpl(capital == true)
>
> $leader1 : LeaderImpl(location == $loc)
>
> then
>
> $result.addPassedRule("leader in capital");
>
> update($result);
>
> end
>
>
>
> rule "leader in homeland"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leader in homeland")
>
> $loc : LocationImpl(homeland == true)
>
> $leader1 : LeaderImpl(location == $loc)
>
> then
>
> $result.addPassedRule("leader in homeland");
>
> update($result);
>
> end
>
>
>
> rule "abdication allowed"
>
> when
>
> $result : RuleResult (rulesPassed not contains "abdication allowed"
>
> && rulesPassed contains "leaders in same location"
>
> && rulesPassed contains "leaders king and heir")
>
> then
>
> $result.addPassedRule("abdication allowed");
>
> update($result);
>
> end
>
>
>  --
>
> *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> *On Behalf Of *Edson Tirelli
> *Sent:* Tuesday, October 30, 2007 2:31 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] RE:
> JavaConsequenceBuilder.buildNullPointerException
>
>
>
>Michael,
>
>Can you show us your rule(s) please? it is raising the NPE when trying
> to get the list of variables you use in the consequence... as soon as we
> determine what the real problem is, I can fix the error message...
>
>[]s
>Edson
>
> 2007/10/30, Michael Fuller <[EMAIL PROTECTED]>:
>
> I have the following code: (note String[] ruleFiles contains only one
> string)
>
>
>
> public class Engine {
>
> private static RuleBase ruleBase;
>
>
>
> public void start(String[] ruleFiles) throws Exception {
>
> PackageBuilderConfiguration cfg = new
> PackageBuilderConfiguration();
>
> JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
> cfg.getDialectConfiguration("java");
>
> javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
>
> PackageBuilder builder = new PackageBuilder(cfg);
>
> for (String file : ruleFiles) {
>
> builder.addPackageFromDrl(new InputStreamReader(
> ClassLoader.getSystemResourceAsStream(file)));
>
> }
>
> Package pkg = builder.getPackage();
>
>
>
> PackageBuilderErrors errors = builder.getErrors();
>
> if (errors.getErrors().length != 0) {
>
> // do something
>
> }
>
>
>
> RuleBaseConfiguration conf = new RuleBaseConfiguration();
>
> conf.setAssertBehaviour(
> RuleBaseConfiguration.AssertBehaviour.EQUALITY);
>
>
>
> ruleBase = RuleBaseFactory.newRuleBase();
>
> ruleBase.addPackage(pkg);
>
> ruleBase.newStatefulSession(false);
>
>
>
> }
>
> }
>
>
>
> At the builder.addPackageFromDrl(new InputStreamReader(
> ClassLoader.getSy

RE: [rules-users] Problem with DSL in Drools 4.0.3

2007-10-31 Thread tansey

I have included a reference to "expander" in my DRL.  The files look as
follows:

(src/main/rules/mylang.dsl)
[consequence][]Log "{msg}"=System.out.println("{msg}");

(src/main/rules/Sample.drl)
package com.sample

expander mylang.dsl

import com.sample.DroolsTest.Message;
 
rule "Hello World"
when
m : Message( status == Message.HELLO, message : message )
then
System.out.println( message ); 
m.setMessage( "Goodbye cruel world" );
m.setStatus( Message.GOODBYE );
update( m );
end

rule "GoodBye"
no-loop true
when
m : Message( status == Message.GOODBYE, message : message )
then
System.out.println( message ); 
m.setMessage( message );

end

(src/main/java/DroolsTest.java)
package com.sample;

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;

/**
 * This is a sample file to launch a rule package from a rule source file.
 */
public class DroolsTest {

public static final void main(String[] args) {
try {

//load up the rulebase
RuleBase ruleBase = readRule();
WorkingMemory workingMemory = ruleBase.newStatefulSession();

//go !
Message message = new Message();
message.setMessage(  "Hello World" );
message.setStatus( Message.HELLO );
workingMemory.insert( message );
workingMemory.fireAllRules();   


} catch (Throwable t) {
t.printStackTrace();
}
}

/**
 * Please note that this is the "low level" rule assembly API.
 */
private static RuleBase readRule() throws Exception {
//read in the source
Reader source = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );

//optionally read in the DSL (if you are using it).
Reader dsl = new InputStreamReader( 
DroolsTest.class.getResourceAsStream(
"/mylang.dsl" ) );

//Use package builder to build up a rule package.
//An alternative lower level class called "DrlParser" can also 
be used...

PackageBuilder builder = new PackageBuilder();

//this wil parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for 
normal DRL.
//builder.addPackageFromDrl( source );

//Use the following instead of above if you are using a DSL:
builder.addPackageFromDrl( source, dsl );

//get the compiled package (which is serializable)
Package pkg = builder.getPackage();
//add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}

public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;

private String message;

private int status;

public String getMessage() {
return this.message;
}

public void setMessage(String message) {
this.message = message;
}

public int getStatus() {
return this.status;
}

public void setStatus( int status ) {
this.status = status;
}
}

}




Anstis, Michael (M.) wrote:
> 
> Can you provide your DRL and DSL?
> 
> Have you included a reference to "expander" in your DRL?
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of tansey
> Sent: 31 October 2007 07:55
> To: rules-users@lists.jboss.org
> Subject: [rules-users] Problem with DSL in Drools 4.0.3
> 
> 
> I'm new to Drools, and I've setup the latest version of it in Eclipse 3.2.
> I'm having trouble whenever I try to use a DSL though.  I took the
> standard
> Hello World example and added the 'mylang.dsl' file, and changed the lines
> in DroolsTest.readRule() as follows:
> 
> private static RuleBase readRule() throws Exception {
>   //read in the source
>   Reader source = new InputStreamReader(
> DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );
>   
>   //optionally rea

RE: [rules-users] RE: JavaConsequenceBuilder.buildNullPointerException

2007-10-31 Thread Michael Fuller
Thank you so very much. Yes, changing the parse to handle this would be
very helpful.

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: Wednesday, October 31, 2007 12:32 PM
To: Rules Users List
Subject: Re: [rules-users] RE:
JavaConsequenceBuilder.buildNullPointerException

 


   Michael,

   The problem is you missed the "" on:

$result.addPassedRule(leaders in same location);


I will fix the parser code to not throw NPE for this anymore.

Thanks,
  Edson

2007/10/31, Michael Fuller <[EMAIL PROTECTED]>:

Sure. Thanks

 

package validActions;

import myPackage.domain.leader.LeaderImpl;

import myPackage.domain.location.LocationImpl;

import myPackage.domain.leader.LeaderTypeImpl;

import myPackage.rivoli.service.rules.RuleResult;

 

rule "leaders in same location"

salience 10

when

$result : RuleResult(rulesPassed not contains "leaders in same
location")

$loc : LocationImpl()

$leaderName : String()

$leader1 : LeaderImpl(name == $leaderName, location == $loc)

$leader2 : LeaderImpl(name != $leaderName, this != $leader1,
location == $loc)

then

$result.addPassedRule(leaders in same location);

update($result);

end

 

rule "leaders king and heir"

salience 10

when

$result : RuleResult(rulesPassed not contains "leaders king and
heir")

$leaderName : String()

$king : LeaderTypeImpl(name == "King")

$heir : LeaderTypeImpl(name == "Heir")

$leader1 : LeaderImpl(name == $leaderName, leaderType == $king)

$leader2 : LeaderImpl(name != $leaderName, this != $leader1,
leaderType == $heir)

then

$result.addPassedRule("leaders king and heir");

update($result);

end

 

rule "leader in capital"

salience 10

when

$result : RuleResult(rulesPassed not contains "leader in capital")

$loc : LocationImpl(capital == true)

$leader1 : LeaderImpl(location == $loc)

then

$result.addPassedRule("leader in capital");

update($result);

end

 

rule "leader in homeland"

salience 10

when

$result : RuleResult(rulesPassed not contains "leader in homeland")

$loc : LocationImpl(homeland == true)

$leader1 : LeaderImpl(location == $loc)

then

$result.addPassedRule("leader in homeland");

update($result);

end

 

rule "abdication allowed"

when

$result : RuleResult (rulesPassed not contains "abdication allowed"

&& rulesPassed contains "leaders in same location"

&& rulesPassed contains "leaders king and heir")

then

$result.addPassedRule("abdication allowed");

update($result);

end

 



From: [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED]
 ] On Behalf Of Edson
Tirelli
Sent: Tuesday, October 30, 2007 2:31 PM
To: Rules Users List
Subject: Re: [rules-users] RE:
JavaConsequenceBuilder.buildNullPointerException

 

   Michael,

   Can you show us your rule(s) please? it is raising the NPE when
trying to get the list of variables you use in the consequence... as
soon as we determine what the real problem is, I can fix the error
message... 

   []s
   Edson

2007/10/30, Michael Fuller <[EMAIL PROTECTED]>:

I have the following code: (note String[] ruleFiles contains only one
string)

 

public class Engine {

private static RuleBase ruleBase;

 

public void start(String[] ruleFiles) throws Exception {

PackageBuilderConfiguration cfg = new
PackageBuilderConfiguration();

JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
cfg.getDialectConfiguration("java");

javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);

PackageBuilder builder = new PackageBuilder(cfg);

for (String file : ruleFiles) {

builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file)));

}

Package pkg = builder.getPackage();

 

PackageBuilderErrors errors = builder.getErrors();

if (errors.getErrors().length != 0) {

// do something

}

 

RuleBaseConfiguration conf = new RuleBaseConfiguration();

 
conf.setAssertBehaviour(RuleBaseConfiguration.AssertBehaviour.EQUALITY);

 

ruleBase = RuleBaseFactory.newRuleBase();

ruleBase.addPackage(pkg);

ruleBase.newStatefulSession(false);

 

}

}

 

At the builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file))); line
I'm getting the following exception:

java.lang.NullPointerException

at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaCo
nsequenceBuilder.java:54)

at
org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)

at
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)

at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)

at
org.drools.compiler.PackageBuilder.addPackag

RE: [rules-users] Executing rules actions asynchronously

2007-10-31 Thread Spyros Sakellariou
My thinking is that when the Web Service returns (asynchronously through JMS
or by an extra thread that you created) to insert the result into the memory
perhaps as a generic reply object so other rules will fire when the object
is inserted, depending of course on the contents of the reply object.  

You will have to use a stateful session for this to work and I think that
you will have to keep calling the fireAllRules() after each returning Web
Service reply is inserted into the working memory.

About JMS it is a much better alternative of creating asynchronous requests
than creating your own threads, as you will find support for Thread Pooling,
Transactions, Priority queues etc. depending on the JMS implementation.  Of
course you can achieve the same with creating your own threads but I think
it will be a lot of work.
 

Spyros



Spyros Sakellariou 
Principal Product Manager - Solution Architect


Markopoulo Ave. 
19002 Paiania Athens, Greece 
Tel. +30 210 667 9874 
Mob. +30 694 700 7984 
email [EMAIL PROTECTED]  


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Carlos Vieira
Sent: Wednesday, October 31, 2007 5:46 PM
To: Rules Users List
Subject: Re: [rules-users] Executing rules actions asynchronously

Hi Spyros,

Well, i tried launching a thread for each Web Service call, and it works
ok... but i need to use the return of Web Service in the right side of
the rule to, for example, insert another fact... so, i have to wait for
the execution...
What i want is to execute a set of actions (in the right side of a rule)
in a different thread.

But i will look for JMS to see capabilities, and to see if fit my purposes.

Thx for the help

Regards
Carlos V.

Spyros Sakellariou wrote:
> Hi Carlos,
>
> I don't know if this is possible in drools but an alternative is instead
of
> calling web services synchronously from drools, to call them
asynchronously
> using JMS.  That way you don't have to wait for each service to return. 
>
> Spyros
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Carlos Vieira
> Sent: Wednesday, October 31, 2007 5:02 PM
> To: rules-users@lists.jboss.org
> Subject: [rules-users] Executing rules actions asynchronously
>
> Hi,
>
> I'm facing a situation, that maybe some of you just solved out in the
past.
> I need that the execution of matched rules ( Activations that are
> already in the Agenda, referencing those rules) is done asynchronously.
>
> In more detail, i need that each set of actions owned by two or more
> rules, runs in a separated thread.
> The problem here is that i need to invoke external Web Services in rule
> actions well, some Web Services may take too long to return
> something, what makes the other actions of other rules to wait for
> this... what is not an expected behavior...
>
> Any one knows if jboss rules already support this kind of approach? If
> not, any one has passed through this?
> Accessing to the mechanism of firing individual rules seems to be the
> best way, overriding a couple of classes. how can i fire just one
> rule with jboss rules? is this the best choice?
>
> Well, if anyone has any idea, it would be nice
>
> Regards
> Carlos V.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Using java.util.List in rules

2007-10-31 Thread Edson Tirelli
   Anderson,

   For some reason, MVEL is not resolving your class. Are you using latest
drools version with latest MVEL jar?
   Can you send me a self contained test with this rule?

   []s
   Edson


2007/10/31, Anderson Pazza Mello <[EMAIL PROTECTED]>:
>
> Do you know why? *
>
> =)
>
> 2007/10/30, Anderson Pazza Mello <[EMAIL PROTECTED]>:
> >
> > Yes I'm Brazilian
> > I need to improve my english I now hehehe
> >
> > About the problem... I solved it.
> >
> > But now I'm getting this error when I use a static property in the
> > rules:
> >
> > Exception in thread "AWT-EventQueue-0" org.drools.RuntimeDroolsException:
> > Exception executing predicate
> > [EMAIL PROTECTED]
> > at org.drools.rule.PredicateConstraint.isAllowed(
> > PredicateConstraint.java:197)
> > at org.drools.reteoo.FromNode.assertTuple(FromNode.java :70)
> > at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> > SingleTupleSinkAdapter.java:29)
> > at org.drools.reteoo.EvalConditionNode.assertTuple(
> > EvalConditionNode.java:150)
> > at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple (
> > SingleTupleSinkAdapter.java:20)
> > at org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> > at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> > SingleTupleSinkAdapter.java:20)
> > at org.drools.reteoo.FromNode.assertTuple (FromNode.java:87)
> > at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> > SingleTupleSinkAdapter.java:20)
> > at org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> > .
> > .
> > .
> >
> > Caused by: org.mvel.PropertyAccessException: unable to resolve property:
> > unable to resolve token: TipoCaracteristica.CABELO_TOTALMENTE_CALVO
> > at org.mvel.ast.PropertyASTNode.initializePropertyNode(
> > PropertyASTNode.java:86)
> > at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(
> > PropertyASTNode.java :23)
> > at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(
> > BinaryOperation.java:20)
> > at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
> > at org.mvel.CompiledExpression.getValue(CompiledExpression.java:99)
> > at org.mvel.MVEL.executeExpression(MVEL.java:219)
> > at org.drools.base.mvel.MVELPredicateExpression.evaluate (
> > MVELPredicateExpression.java:36)
> > at org.drools.rule.PredicateConstraint.isAllowed(
> > PredicateConstraint.java:191)
> > ... 44 more
> >
> > Example:
> >
> > Property :
> > public class TipoCaracteristica implements java.io.Serializable{
> > .
> > .
> >
> > public static int CABELO_TOTALMENTE_CALVO = 37;
> > .
> > .
> > .
> > }
> >
> > rule:
> >
> > rule "CABELO_TOTALMENTE_CALVO resposta nao / Chama Tipo de Cabelo"
> > salience 90
> > when
> > e : Especialista(perguntado == false)
> > Especialista( $retrato : retratoUser)
> > Retrato($lstCaracRetrato : lstCarac) from $retrato
> > Retrato($lstMolde : lstMolde) from $retrato
> > Molde(tipoMolde.codTipMolde == TipoMolde.CABELO &&
> > $lstCaracMolde: lstCarac) from $lstMolde
> > //CABELO_TIPO = 10
> > eval(naoPerguntou($lstCaracMolde, 10))
> > //CABELO_TOTALMENTE_CALVO = 37 e RESPOSTA_SIM = 154
> > Caracteristica(tipCarac.codTipCarac ==
> > TipoCaracteristica.CABELO_TOTALMENTE_CALVO && valor.codValor == 154)
> > from $lstCaracMolde
> > then
> > buscarMontarPergunta(e,Pergunta.CABELO_TIPO,Especialista.CABELO
> > );
> > e.perguntado = true;
> > update(e);
> > end
> >
> > I get some statics properties like "TipoMolde.CABELO" without errors,
> > but I can't use the properties from this class (TipoCaracteristica). Did you
> > know why?
> > If I use de value like this " valor.codValor == 154", I have no problem.
> >
> > 2007/10/29, Edson Tirelli < [EMAIL PROTECTED]>:
> > >
> > >
> > > Anderson,
> > >
> > > What is the error? Can you provide a self contained example?
> > > Using the "from CE" as showed before works.
> > >
> > > BTW, are you Brazilian? Your name sounds like a Brazilian name.
> > >
> > >  []s
> > >  Edson
> > >
> > > 2007/10/27, Anderson Pazza Mello <[EMAIL PROTECTED] >:
> > > >
> > > > How can I test all elements of the list?
> > > > Can I need to use something like "for (int i.)"?
> > > >
> > > > I'm trying to do that but it is not working...
> > > >
> > > > "Caracteristica( codCarac != 0 ) from $caracList"
> > > >
> > > >
> > > >
> > > > My test:
> > > >
> > > > e : Especialista (perguntado == false)
> > > > Especialista( $moldeList : retratoUser.lstMolde )
> > > > Molde( tipoMolde == TipoMolde.CABELO) from $moldeList
> > > >
> > > >
> > > > When  the property  "tipoMolde == TipoMolde.CABELO" the rule must to
> > > > be fired. The List $moldeList has 5 elements.
> > > >
> > > > any idea?
> > > >
> > > >
> > > > 2007/10/3, Edson Tirelli < [EMAIL PROTECTED]>:
> > > > >
> > > > >   Use the "from" CE:
> > > > >
> > > > 

Re: [rules-users] RE: JavaConsequenceBuilder.buildNullPointerException

2007-10-31 Thread Edson Tirelli
   Michael,

   The problem is you missed the "" on:

$result.addPassedRule(leaders in same location);

I will fix the parser code to not throw NPE for this anymore.

Thanks,
  Edson

2007/10/31, Michael Fuller <[EMAIL PROTECTED]>:
>
>  Sure. Thanks
>
>
>
> package validActions;
>
> import myPackage.domain.leader.LeaderImpl;
>
> import myPackage.domain.location.LocationImpl;
>
> import myPackage.domain.leader.LeaderTypeImpl;
>
> import myPackage.rivoli.service.rules.RuleResult;
>
>
>
> rule "leaders in same location"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leaders in same
> location")
>
> $loc : LocationImpl()
>
> $leaderName : String()
>
> $leader1 : LeaderImpl(name == $leaderName, location == $loc)
>
> $leader2 : LeaderImpl(name != $leaderName, this != $leader1, location
> == $loc)
>
> then
>
> $result.addPassedRule(leaders in same location);
>
> update($result);
>
> end
>
>
>
> rule "leaders king and heir"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leaders king and heir")
>
> $leaderName : String()
>
> $king : LeaderTypeImpl(name == "King")
>
> $heir : LeaderTypeImpl(name == "Heir")
>
> $leader1 : LeaderImpl(name == $leaderName, leaderType == $king)
>
> $leader2 : LeaderImpl(name != $leaderName, this != $leader1,
> leaderType == $heir)
>
> then
>
> $result.addPassedRule("leaders king and heir");
>
> update($result);
>
> end
>
>
>
> rule "leader in capital"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leader in capital")
>
> $loc : LocationImpl(capital == true)
>
> $leader1 : LeaderImpl(location == $loc)
>
> then
>
> $result.addPassedRule("leader in capital");
>
> update($result);
>
> end
>
>
>
> rule "leader in homeland"
>
> salience 10
>
> when
>
> $result : RuleResult(rulesPassed not contains "leader in homeland")
>
> $loc : LocationImpl(homeland == true)
>
> $leader1 : LeaderImpl(location == $loc)
>
> then
>
> $result.addPassedRule("leader in homeland");
>
> update($result);
>
> end
>
>
>
> rule "abdication allowed"
>
> when
>
> $result : RuleResult (rulesPassed not contains "abdication allowed"
>
> && rulesPassed contains "leaders in same location"
>
> && rulesPassed contains "leaders king and heir")
>
> then
>
> $result.addPassedRule("abdication allowed");
>
> update($result);
>
> end
>
>
>  --
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Edson Tirelli
> *Sent:* Tuesday, October 30, 2007 2:31 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] RE:
> JavaConsequenceBuilder.buildNullPointerException
>
>
>
>Michael,
>
>Can you show us your rule(s) please? it is raising the NPE when trying
> to get the list of variables you use in the consequence... as soon as we
> determine what the real problem is, I can fix the error message...
>
>[]s
>Edson
>
> 2007/10/30, Michael Fuller <[EMAIL PROTECTED]>:
>
> I have the following code: (note String[] ruleFiles contains only one
> string)
>
>
>
> public class Engine {
>
> private static RuleBase ruleBase;
>
>
>
> public void start(String[] ruleFiles) throws Exception {
>
> PackageBuilderConfiguration cfg = new
> PackageBuilderConfiguration();
>
> JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
> cfg.getDialectConfiguration("java");
>
> javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
>
> PackageBuilder builder = new PackageBuilder(cfg);
>
> for (String file : ruleFiles) {
>
> builder.addPackageFromDrl(new InputStreamReader(
> ClassLoader.getSystemResourceAsStream(file)));
>
> }
>
> Package pkg = builder.getPackage();
>
>
>
> PackageBuilderErrors errors = builder.getErrors();
>
> if (errors.getErrors().length != 0) {
>
> // do something
>
> }
>
>
>
> RuleBaseConfiguration conf = new RuleBaseConfiguration();
>
> conf.setAssertBehaviour(
> RuleBaseConfiguration.AssertBehaviour.EQUALITY);
>
>
>
> ruleBase = RuleBaseFactory.newRuleBase();
>
> ruleBase.addPackage(pkg);
>
> ruleBase.newStatefulSession(false);
>
>
>
> }
>
> }
>
>
>
> At the builder.addPackageFromDrl(new InputStreamReader(
> ClassLoader.getSystemResourceAsStream(file))); line I'm getting the
> following exception:
>
> java.lang.NullPointerException
>
> at
> org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(
> JavaConsequenceBuilder.java:54)
>
> at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java
> :67)
>
> at org.drools.compiler.PackageBuilder.addRule(
> PackageBuilder.java:446)
>
> at org.drools.compiler.PackageBuilder.addPackage(
> PackageBuilder.java:304)
>
> at org.drools.compiler.PackageBuilder.addPackageFromDrl(
> 

Re: [rules-users] Executing rules actions asynchronously

2007-10-31 Thread Carlos Vieira
Hi Spyros,

Well, i tried launching a thread for each Web Service call, and it works
ok... but i need to use the return of Web Service in the right side of
the rule to, for example, insert another fact... so, i have to wait for
the execution...
What i want is to execute a set of actions (in the right side of a rule)
in a different thread.

But i will look for JMS to see capabilities, and to see if fit my purposes.

Thx for the help

Regards
Carlos V.

Spyros Sakellariou wrote:
> Hi Carlos,
>
> I don't know if this is possible in drools but an alternative is instead of
> calling web services synchronously from drools, to call them asynchronously
> using JMS.  That way you don't have to wait for each service to return. 
>
> Spyros
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Carlos Vieira
> Sent: Wednesday, October 31, 2007 5:02 PM
> To: rules-users@lists.jboss.org
> Subject: [rules-users] Executing rules actions asynchronously
>
> Hi,
>
> I'm facing a situation, that maybe some of you just solved out in the past.
> I need that the execution of matched rules ( Activations that are
> already in the Agenda, referencing those rules) is done asynchronously.
>
> In more detail, i need that each set of actions owned by two or more
> rules, runs in a separated thread.
> The problem here is that i need to invoke external Web Services in rule
> actions well, some Web Services may take too long to return
> something, what makes the other actions of other rules to wait for
> this... what is not an expected behavior...
>
> Any one knows if jboss rules already support this kind of approach? If
> not, any one has passed through this?
> Accessing to the mechanism of firing individual rules seems to be the
> best way, overriding a couple of classes. how can i fire just one
> rule with jboss rules? is this the best choice?
>
> Well, if anyone has any idea, it would be nice
>
> Regards
> Carlos V.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   

begin:vcard
fn:Carlos Vieira
n:Vieira;Carlos
org;quoted-printable:Telbit - Tecnologias de Informa=C3=A7=C3=A3o
email;internet:[EMAIL PROTECTED]
version:2.1
end:vcard

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Executing rules actions asynchronously

2007-10-31 Thread Spyros Sakellariou
Hi Carlos,

I don't know if this is possible in drools but an alternative is instead of
calling web services synchronously from drools, to call them asynchronously
using JMS.  That way you don't have to wait for each service to return. 

Spyros


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Carlos Vieira
Sent: Wednesday, October 31, 2007 5:02 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Executing rules actions asynchronously

Hi,

I'm facing a situation, that maybe some of you just solved out in the past.
I need that the execution of matched rules ( Activations that are
already in the Agenda, referencing those rules) is done asynchronously.

In more detail, i need that each set of actions owned by two or more
rules, runs in a separated thread.
The problem here is that i need to invoke external Web Services in rule
actions well, some Web Services may take too long to return
something, what makes the other actions of other rules to wait for
this... what is not an expected behavior...

Any one knows if jboss rules already support this kind of approach? If
not, any one has passed through this?
Accessing to the mechanism of firing individual rules seems to be the
best way, overriding a couple of classes. how can i fire just one
rule with jboss rules? is this the best choice?

Well, if anyone has any idea, it would be nice

Regards
Carlos V.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Executing rules actions asynchronously

2007-10-31 Thread Carlos Vieira
Hi,

I'm facing a situation, that maybe some of you just solved out in the past.
I need that the execution of matched rules ( Activations that are
already in the Agenda, referencing those rules) is done asynchronously.

In more detail, i need that each set of actions owned by two or more
rules, runs in a separated thread.
The problem here is that i need to invoke external Web Services in rule
actions well, some Web Services may take too long to return
something, what makes the other actions of other rules to wait for
this... what is not an expected behavior...

Any one knows if jboss rules already support this kind of approach? If
not, any one has passed through this?
Accessing to the mechanism of firing individual rules seems to be the
best way, overriding a couple of classes. how can i fire just one
rule with jboss rules? is this the best choice?

Well, if anyone has any idea, it would be nice

Regards
Carlos V.
begin:vcard
fn:Carlos Vieira
n:Vieira;Carlos
org;quoted-printable:Telbit - Tecnologias de Informa=C3=A7=C3=A3o
email;internet:[EMAIL PROTECTED]
version:2.1
end:vcard

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Problem running JBRMS 4.0.3 on JBoss AS 4.2.1

2007-10-31 Thread Fernando Meyer
Ok guys, Im check this problem at the moment/.

On 10/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I think there must be a bug with the 4.0.3 BRMS .war file.  I upgraded
> to 4.0.3 (including the BRMS .war file) and received the same errors
> listed below when tring to login to the BRMS.  I then copied the 4.0.1
> BRMS .war file to the server/deploy directory and everything works fine.
> I also did a scan for 'drools-jbrms*' and deleted all files/folders each
> time.  All files are version 4.0.3 except for the .war file which is 4.0.1
> .
> Any response from the Drools developers, does the 4.0.3 .war file not
> work?
>
> On Wed, Oct 31, 2007 at 07:05:53AM -0700, Aziz Boxwala wrote:
> > Switching to AS 4.2.0 may not be an easy option for us. Much of our
> development
> > product development has been done with 4.2.1.
> >
> > I did not have this problem with BRMS 4.0.0 running on AS 4.2.1.
> >
> > I should clarify that the exception is thrown when trying to login to
> the BRMS.
> >
> > If there is no resolution, is it possible to get to earlier builds (
> 4.0.0
> > latest, or 4.0.1). The downloads page only lists 4.0.3.
> >
> > Thanks,
> > --Aziz
> >
> >
> -
> > Aziz
> >
> > I have/had the same problem under Windows NT.  I never received a
> > resolution so I just stayed with 4.2.0.  It must not work with 4.2.1.
> >
> > Rod
> > On Fri, Oct 26, 2007 at 09:27:23AM -0700, Aziz Boxwala wrote:
> > > I cannot
> >  get the BRMS to run on JBoss AS 4.2.1. (on Windows Vista).
> > >
> > > Any help/hints to fix this will be appreciated. This is the error I
> get:
> > >
> > > 12:19:03,577 INFO  [STDOUT] ERROR 26-10 12:19:03,576
> > > (Contexts.java:flushAndDestroyContexts:335) could not discover
> > > transaction status
> > > 12:19:03,579 INFO  [STDOUT] ERROR 26-10 12:19:03,578
> > > (StandardWrapperValve.java:invoke:278)  Servlet.service() for s
> > > ervlet default threw exception
> > > java.lang.IllegalStateException: Cannot create a session after the
> response has
> > > been committed
> > > at org.apache.catalina.connector.Request.doGetSession
> > > (Request.java:2284)
> > > at org.apache.catalina.connector.Request.getSession(
> Request.java:2066)
> > > at
> >  org.apache.catalina.connector.RequestFacade.getSession
> > > (RequestFacade.java:833)
> > > at org.jboss.seam.servlet.ServletRequestSessionMap.put
> > > (ServletRequestSessionMap.java:87)
> > > at org.jboss.seam.servlet.ServletRequestSessionMap.put
> > > (ServletRequestSessionMap.java:25)
> > > at org.jboss.seam.contexts.BasicContext.set(BasicContext.java
> :80)
> > > at org.jboss.seam.Component.newInstance(Component.java:1980)
> > > at org.jboss.seam.Component.getInstance(Component.java:1878)
> > > at org.jboss.seam.Component.getInstance(Component.java:1857)
> > > at org.jboss.seam.Component.getInstance(Component.java:1834)
> > > at org.jboss.seam.web.Session.getInstance(Session.java:122)
> > > at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts
> > >
> >  (Contexts.java:375)
> > > at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java
> :132)
> > > at org.jboss.seam.servlet.ContextualHttpServletRequest.run
> > > (ContextualHttpServletRequest.java:65)
> > > at org.jboss.seam.web.ContextFilter.doFilter(
> ContextFilter.java:37)
> > > at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> > > (ApplicationFilterChain.java:235)
> > > at org.apache.catalina.core.ApplicationFilterChain.doFilter
> > > (ApplicationFilterChain.java:206)
> > > at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter
> > > (ReplyHeaderFilter.java:96)
> > > at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> > > (ApplicationFilterChain.java:235)
> > > at
> >  org.apache.catalina.core.ApplicationFilterChain.doFilter
> > > (ApplicationFilterChain.java:206)
> > > at org.apache.catalina.core.StandardWrapperValve.invoke
> > > (StandardWrapperValve.java:230)
> > > at org.apache.catalina.core.StandardContextValve.invoke
> > > (StandardContextValve.java:175)
> > > at
> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
> > > (SecurityAssociationValve.java:179)
> > > at org.jboss.web.tomcat.security.JaccContextValve.invoke
> > > (JaccContextValve.java:84)
> > > at org.apache.catalina.core.StandardHostValve.invoke
> > > (StandardHostValve.java:128)
> > > at org.apache.catalina.valves.ErrorReportValve.invoke
> > > (ErrorReportValve.java:104)
> > > at
> org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
> > >
> >  (CachedConnectionValve.java:157)
> > > at org.apache.catalina.core.StandardEngineValve.invoke
> > > (StandardEngineValve.java:109)
> > > at org.apache.catalina.connector.CoyoteAdap

Re: [rules-users] Problem running JBRMS 4.0.3 on JBoss AS 4.2.1

2007-10-31 Thread kissro
I think there must be a bug with the 4.0.3 BRMS .war file.  I upgraded
to 4.0.3 (including the BRMS .war file) and received the same errors
listed below when tring to login to the BRMS.  I then copied the 4.0.1
BRMS .war file to the server/deploy directory and everything works fine.
I also did a scan for 'drools-jbrms*' and deleted all files/folders each
time.  All files are version 4.0.3 except for the .war file which is 4.0.1.
Any response from the Drools developers, does the 4.0.3 .war file not
work?

On Wed, Oct 31, 2007 at 07:05:53AM -0700, Aziz Boxwala wrote:
> Switching to AS 4.2.0 may not be an easy option for us. Much of our 
> development
> product development has been done with 4.2.1.
> 
> I did not have this problem with BRMS 4.0.0 running on AS 4.2.1.
> 
> I should clarify that the exception is thrown when trying to login to the 
> BRMS.
> 
> If there is no resolution, is it possible to get to earlier builds (4.0.0
> latest, or 4.0.1). The downloads page only lists 4.0.3.
> 
> Thanks,
> --Aziz
> 
> -
> Aziz
> 
> I have/had the same problem under Windows NT.  I never received a
> resolution so I just stayed with 4.2.0.  It must not work with 4.2.1.
> 
> Rod
> On Fri, Oct 26, 2007 at 09:27:23AM -0700, Aziz Boxwala wrote:
> > I cannot
>  get the BRMS to run on JBoss AS 4.2.1. (on Windows Vista).
> > 
> > Any help/hints to fix this will be appreciated. This is the error I get:
> > 
> > 12:19:03,577 INFO  [STDOUT] ERROR 26-10 12:19:03,576
> > (Contexts.java:flushAndDestroyContexts:335) could not discover
> > transaction status
> > 12:19:03,579 INFO  [STDOUT] ERROR 26-10 12:19:03,578
> > (StandardWrapperValve.java:invoke:278)  Servlet.service() for s
> > ervlet default threw exception
> > java.lang.IllegalStateException: Cannot create a session after the response 
> > has
> > been committed
> > at org.apache.catalina.connector.Request.doGetSession
> > (Request.java:2284)
> > at 
> > org.apache.catalina.connector.Request.getSession(Request.java:2066)
> > at
>  org.apache.catalina.connector.RequestFacade.getSession
> > (RequestFacade.java:833)
> > at org.jboss.seam.servlet.ServletRequestSessionMap.put
> > (ServletRequestSessionMap.java:87)
> > at org.jboss.seam.servlet.ServletRequestSessionMap.put
> > (ServletRequestSessionMap.java:25)
> > at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
> > at org.jboss.seam.Component.newInstance(Component.java:1980)
> > at org.jboss.seam.Component.getInstance(Component.java:1878)
> > at org.jboss.seam.Component.getInstance(Component.java:1857)
> > at org.jboss.seam.Component.getInstance(Component.java:1834)
> > at org.jboss.seam.web.Session.getInstance(Session.java:122)
> > at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts
> >
>  (Contexts.java:375)
> > at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:132)
> > at org.jboss.seam.servlet.ContextualHttpServletRequest.run
> > (ContextualHttpServletRequest.java:65)
> > at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
> > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> > (ApplicationFilterChain.java:235)
> > at org.apache.catalina.core.ApplicationFilterChain.doFilter
> > (ApplicationFilterChain.java:206)
> > at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter
> > (ReplyHeaderFilter.java:96)
> > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> > (ApplicationFilterChain.java:235)
> > at
>  org.apache.catalina.core.ApplicationFilterChain.doFilter
> > (ApplicationFilterChain.java:206)
> > at org.apache.catalina.core.StandardWrapperValve.invoke
> > (StandardWrapperValve.java:230)
> > at org.apache.catalina.core.StandardContextValve.invoke
> > (StandardContextValve.java:175)
> > at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
> > (SecurityAssociationValve.java:179)
> > at org.jboss.web.tomcat.security.JaccContextValve.invoke
> > (JaccContextValve.java:84)
> > at org.apache.catalina.core.StandardHostValve.invoke
> > (StandardHostValve.java:128)
> > at org.apache.catalina.valves.ErrorReportValve.invoke
> > (ErrorReportValve.java:104)
> > at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
> >
>  (CachedConnectionValve.java:157)
> > at org.apache.catalina.core.StandardEngineValve.invoke
> > (StandardEngineValve.java:109)
> > at org.apache.catalina.connector.CoyoteAdapter.service
> > (CoyoteAdapter.java:241)
> > at org.apache.coyote.http11.Http11Processor.process
> > (Http11Processor.java:844)
> > at
> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process
> > (Http11Protocol.java:580)
> > at org.apache.tomcat.util.net.JIoEndpoint

[rules-users] Problem drools-ant 4.0.2

2007-10-31 Thread Arnaud Bouzinac
I try to generate a pkg file from a drl file

so , i'm using drools-ant task (version 4.0.2)

when i load my pkg file, there's a classcast exception:

java.lang.ClassCastException: org.drools.reteoo.ReteooRuleBase cannot be
cast to org.drools.rule.Package
at org.drools.agent.FileScanner.readPackage(FileScanner.java:109)
at org.drools.agent.FileScanner.getChangeSet(FileScanner.java:79)
at org.drools.agent.FileScanner.loadPackageChanges(FileScanner.java:57)
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)
at org.drools.agent.RuleAgent.init(RuleAgent.java:208)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:176)
at org.drools.agent.RuleAgent.newRuleAgent(RuleAgent.java:148)
at
fr.biomerieux.qi.algo.common.inferenceengine.InferenceEngineControllerImpl.initializeRuleBaseFromPKG
(InferenceEngineControllerImpl.java:128)
at
fr.biomerieux.qi.algorithms.testcase.inferenceengine.InferenceEngineTestCase.testInferenceEngineCase
(InferenceEngineTestCase.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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)
at fr.biomerieux.junit.BmxTestCase.run(BmxTestCase.java:64)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(
JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
RemoteTestRunner.java:196)
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Problem running JBRMS 4.0.3 on JBoss AS 4.2.1

2007-10-31 Thread Aziz Boxwala
Switching to AS 4.2.0 may not be an easy option for us. Much of our development 
product development has been done with 4.2.1.

I did not have this problem with BRMS 4.0.0 running on AS 4.2.1. 

I should clarify that the exception is thrown when trying to login to the BRMS.

If there is no resolution, is it possible to get to earlier builds (4.0.0 
latest, or 4.0.1). The downloads page only lists 4.0.3.

Thanks,
--Aziz

-
Aziz

I have/had the same problem under Windows NT.  I never received a
resolution so I just stayed with 4.2.0.  It must not work with 4.2.1.

Rod
On Fri, Oct 26, 2007 at 09:27:23AM -0700, Aziz Boxwala wrote:
> I cannot get the BRMS to run on JBoss AS 4.2.1. (on Windows Vista).
> 
> Any help/hints to fix this will be appreciated. This is the error I get:
> 
> 12:19:03,577 INFO  [STDOUT] ERROR 26-10 12:19:03,576
> (Contexts.java:flushAndDestroyContexts:335) could not discover
> transaction status
> 12:19:03,579 INFO  [STDOUT] ERROR 26-10 12:19:03,578
> (StandardWrapperValve.java:invoke:278)  Servlet.service() for s
> ervlet default threw exception
> java.lang.IllegalStateException: Cannot create a session after the response 
> has
> been committed
> at org.apache.catalina.connector.Request.doGetSession
> (Request.java:2284)
> at org.apache.catalina.connector.Request.getSession(Request.java:2066)
> at org.apache.catalina.connector.RequestFacade.getSession
> (RequestFacade.java:833)
> at org.jboss.seam.servlet.ServletRequestSessionMap.put
> (ServletRequestSessionMap.java:87)
> at org.jboss.seam.servlet.ServletRequestSessionMap.put
> (ServletRequestSessionMap.java:25)
> at org.jboss.seam.contexts.BasicContext.set(BasicContext.java:80)
> at org.jboss.seam.Component.newInstance(Component.java:1980)
> at org.jboss.seam.Component.getInstance(Component.java:1878)
> at org.jboss.seam.Component.getInstance(Component.java:1857)
> at org.jboss.seam.Component.getInstance(Component.java:1834)
> at org.jboss.seam.web.Session.getInstance(Session.java:122)
> at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts
> (Contexts.java:375)
> at org.jboss.seam.contexts.Lifecycle.endRequest(Lifecycle.java:132)
> at org.jboss.seam.servlet.ContextualHttpServletRequest.run
> (ContextualHttpServletRequest.java:65)
> at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> (ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter
> (ApplicationFilterChain.java:206)
> at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter
> (ReplyHeaderFilter.java:96)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
> (ApplicationFilterChain.java:235)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter
> (ApplicationFilterChain.java:206)
> at org.apache.catalina.core.StandardWrapperValve.invoke
> (StandardWrapperValve.java:230)
> at org.apache.catalina.core.StandardContextValve.invoke
> (StandardContextValve.java:175)
> at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
> (SecurityAssociationValve.java:179)
> at org.jboss.web.tomcat.security.JaccContextValve.invoke
> (JaccContextValve.java:84)
> at org.apache.catalina.core.StandardHostValve.invoke
> (StandardHostValve.java:128)
> at org.apache.catalina.valves.ErrorReportValve.invoke
> (ErrorReportValve.java:104)
> at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
> (CachedConnectionValve.java:157)
> at org.apache.catalina.core.StandardEngineValve.invoke
> (StandardEngineValve.java:109)
> at org.apache.catalina.connector.CoyoteAdapter.service
> (CoyoteAdapter.java:241)
> at org.apache.coyote.http11.Http11Processor.process
> (Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process
> (Http11Protocol.java:580)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
> (JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:595)
> 
> Thanks,
> --Aziz
> 

> ___
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] RE: JavaConsequenceBuilder.buildNullPointerException

2007-10-31 Thread Michael Fuller
Sure. Thanks

 

package validActions;

import myPackage.domain.leader.LeaderImpl;

import myPackage.domain.location.LocationImpl;

import myPackage.domain.leader.LeaderTypeImpl;

import myPackage.rivoli.service.rules.RuleResult;

 

rule "leaders in same location"

salience 10

when

$result : RuleResult(rulesPassed not contains "leaders in same
location")

$loc : LocationImpl()

$leaderName : String()

$leader1 : LeaderImpl(name == $leaderName, location == $loc)

$leader2 : LeaderImpl(name != $leaderName, this != $leader1,
location == $loc)

then

$result.addPassedRule(leaders in same location);

update($result);

end

 

rule "leaders king and heir"

salience 10

when

$result : RuleResult(rulesPassed not contains "leaders king and
heir")

$leaderName : String()

$king : LeaderTypeImpl(name == "King")

$heir : LeaderTypeImpl(name == "Heir")

$leader1 : LeaderImpl(name == $leaderName, leaderType == $king)

$leader2 : LeaderImpl(name != $leaderName, this != $leader1,
leaderType == $heir)

then

$result.addPassedRule("leaders king and heir");

update($result);

end

 

rule "leader in capital"

salience 10

when

$result : RuleResult(rulesPassed not contains "leader in capital")

$loc : LocationImpl(capital == true)

$leader1 : LeaderImpl(location == $loc)

then

$result.addPassedRule("leader in capital");

update($result);

end

 

rule "leader in homeland"

salience 10

when

$result : RuleResult(rulesPassed not contains "leader in homeland")

$loc : LocationImpl(homeland == true)

$leader1 : LeaderImpl(location == $loc)

then

$result.addPassedRule("leader in homeland");

update($result);

end

 

rule "abdication allowed"

when

$result : RuleResult (rulesPassed not contains "abdication allowed"

&& rulesPassed contains "leaders in same location"

&& rulesPassed contains "leaders king and heir")

then

$result.addPassedRule("abdication allowed");

update($result);

end

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: Tuesday, October 30, 2007 2:31 PM
To: Rules Users List
Subject: Re: [rules-users] RE:
JavaConsequenceBuilder.buildNullPointerException

 

   Michael,

   Can you show us your rule(s) please? it is raising the NPE when
trying to get the list of variables you use in the consequence... as
soon as we determine what the real problem is, I can fix the error
message... 

   []s
   Edson

2007/10/30, Michael Fuller <[EMAIL PROTECTED]>:

I have the following code: (note String[] ruleFiles contains only one
string)

 

public class Engine {

private static RuleBase ruleBase;

 

public void start(String[] ruleFiles) throws Exception {

PackageBuilderConfiguration cfg = new
PackageBuilderConfiguration();

JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
cfg.getDialectConfiguration("java");

javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);

PackageBuilder builder = new PackageBuilder(cfg);

for (String file : ruleFiles) {

builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file)));

}

Package pkg = builder.getPackage();

 

PackageBuilderErrors errors = builder.getErrors();

if (errors.getErrors().length != 0) {

// do something

}

 

RuleBaseConfiguration conf = new RuleBaseConfiguration();

 
conf.setAssertBehaviour(RuleBaseConfiguration.AssertBehaviour.EQUALITY);

 

ruleBase = RuleBaseFactory.newRuleBase();

ruleBase.addPackage(pkg);

ruleBase.newStatefulSession(false);

 

}

}

 

At the builder.addPackageFromDrl(new
InputStreamReader(ClassLoader.getSystemResourceAsStream(file))); line
I'm getting the following exception:

java.lang.NullPointerException

at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaCo
nsequenceBuilder.java:54)

at
org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)

at
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)

at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)

at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
:167)

at
myPackage.rivoli.service.rules.Engine.start(Engine.java:33)

at
myPackage.rivoli.rules.LeaderKingAndHeirTest.setUp(LeaderKingAndHeirTest
.java:26)

at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)

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
com.intellij.rt.execution.application.AppM

Re: [rules-users] Using java.util.List in rules

2007-10-31 Thread Anderson Pazza Mello
Do you know why? *

=)

2007/10/30, Anderson Pazza Mello <[EMAIL PROTECTED]>:
>
> Yes I'm Brazilian
> I need to improve my english I now hehehe
>
> About the problem... I solved it.
>
> But now I'm getting this error when I use a static property in the rules:
>
> Exception in thread "AWT-EventQueue-0" org.drools.RuntimeDroolsException:
> Exception executing predicate
> [EMAIL PROTECTED]
> at org.drools.rule.PredicateConstraint.isAllowed(
> PredicateConstraint.java:197)
> at org.drools.reteoo.FromNode.assertTuple(FromNode.java:70)
> at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:29)
> at org.drools.reteoo.EvalConditionNode.assertTuple(
> EvalConditionNode.java:150)
> at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple (
> SingleTupleSinkAdapter.java:20)
> at org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:20)
> at org.drools.reteoo.FromNode.assertTuple (FromNode.java:87)
> at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(
> SingleTupleSinkAdapter.java:20)
> at org.drools.reteoo.FromNode.assertTuple(FromNode.java:87)
> .
> .
> .
>
> Caused by: org.mvel.PropertyAccessException: unable to resolve property:
> unable to resolve token: TipoCaracteristica.CABELO_TOTALMENTE_CALVO
> at org.mvel.ast.PropertyASTNode.initializePropertyNode(
> PropertyASTNode.java:86)
> at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(
> PropertyASTNode.java :23)
> at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(
> BinaryOperation.java:20)
> at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
> at org.mvel.CompiledExpression.getValue(CompiledExpression.java:99)
> at org.mvel.MVEL.executeExpression(MVEL.java:219)
> at org.drools.base.mvel.MVELPredicateExpression.evaluate (
> MVELPredicateExpression.java:36)
> at org.drools.rule.PredicateConstraint.isAllowed(
> PredicateConstraint.java:191)
> ... 44 more
>
> Example:
>
> Property :
> public class TipoCaracteristica implements java.io.Serializable{
> .
> .
>
> public static int CABELO_TOTALMENTE_CALVO = 37;
> .
> .
> .
> }
>
> rule:
>
> rule "CABELO_TOTALMENTE_CALVO resposta nao / Chama Tipo de Cabelo"
> salience 90
> when
> e : Especialista(perguntado == false)
> Especialista( $retrato : retratoUser)
> Retrato($lstCaracRetrato : lstCarac) from $retrato
> Retrato($lstMolde : lstMolde) from $retrato
> Molde(tipoMolde.codTipMolde == TipoMolde.CABELO && $lstCaracMolde:
> lstCarac) from $lstMolde
> //CABELO_TIPO = 10
> eval(naoPerguntou($lstCaracMolde, 10))
> //CABELO_TOTALMENTE_CALVO = 37 e RESPOSTA_SIM = 154
> Caracteristica(tipCarac.codTipCarac ==
> TipoCaracteristica.CABELO_TOTALMENTE_CALVO && valor.codValor == 154) from
> $lstCaracMolde
> then
> buscarMontarPergunta(e,Pergunta.CABELO_TIPO,Especialista.CABELO);
> e.perguntado = true;
> update(e);
> end
>
> I get some statics properties like "TipoMolde.CABELO" without errors, but
> I can't use the properties from this class (TipoCaracteristica). Did you
> know why?
> If I use de value like this " valor.codValor == 154", I have no problem.
>
> 2007/10/29, Edson Tirelli <[EMAIL PROTECTED]>:
> >
> >
> > Anderson,
> >
> > What is the error? Can you provide a self contained example?
> > Using the "from CE" as showed before works.
> >
> > BTW, are you Brazilian? Your name sounds like a Brazilian name.
> >
> >  []s
> >  Edson
> >
> > 2007/10/27, Anderson Pazza Mello <[EMAIL PROTECTED] >:
> > >
> > > How can I test all elements of the list?
> > > Can I need to use something like "for (int i.)"?
> > >
> > > I'm trying to do that but it is not working...
> > >
> > > "Caracteristica( codCarac != 0 ) from $caracList"
> > >
> > >
> > >
> > > My test:
> > >
> > > e : Especialista (perguntado == false)
> > > Especialista( $moldeList : retratoUser.lstMolde )
> > > Molde( tipoMolde == TipoMolde.CABELO) from $moldeList
> > >
> > >
> > > When  the property  "tipoMolde == TipoMolde.CABELO" the rule must to
> > > be fired. The List $moldeList has 5 elements.
> > >
> > > any idea?
> > >
> > >
> > > 2007/10/3, Edson Tirelli < [EMAIL PROTECTED]>:
> > > >
> > > >   Use the "from" CE:
> > > >
> > > > rule "This rule will fire once for each Caracteristica whose
> > > > codCarac is != 0"
> > > > when
> > > > Especialista( $caracList : retratoUser.lstCarac )
> > > > Caracteristica( codCarac != 0 ) from $caracList
> > > > then
> > > > ...
> > > > end
> > > >
> > > >[]s
> > > >Edson
> > > >
> > > > 2007/10/3, Bhattacharya, Sougata <
> > > > [EMAIL PROTECTED]>:
> > > > >
> > > > >  If I want to test for all ith element,
> > > > >
> > > > > Like this
> > > > >
> > > > >
> > > > >
> > > > > rule "Test"
> > > > >
> >

[rules-users] DroolsTab annoncement

2007-10-31 Thread Ru

Hello rules-users,

DroolsTab (former JBRSTab) - DROOLS BASED SPATIAL SCENARIO SIMULATION  
PLUG-IN TO PROTEGE - published on http://oogis.ru/component/ 
option,com_remository/Itemid,34/func,fileinfo/id,2/lang,en/


New features:
- Drools 4 rule engine support
- Parallel tasks instead of sequential phases in scenarios
- new exciting examples with accent on rule sets authoring

Sincerely,

Ru

Ruslan P. Sorokin   [EMAIL PROTECTED]
OOGIS RLhttp://www.oogis.ru
SPIIRAS http://www.spiiras.nw.ru
St.Petersburg
Russia

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Problem with DSL in Drools 4.0.3

2007-10-31 Thread Anstis, Michael (M.)
Can you provide your DRL and DSL?

Have you included a reference to "expander" in your DRL?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of tansey
Sent: 31 October 2007 07:55
To: rules-users@lists.jboss.org
Subject: [rules-users] Problem with DSL in Drools 4.0.3


I'm new to Drools, and I've setup the latest version of it in Eclipse 3.2.
I'm having trouble whenever I try to use a DSL though.  I took the standard
Hello World example and added the 'mylang.dsl' file, and changed the lines
in DroolsTest.readRule() as follows:

private static RuleBase readRule() throws Exception {
//read in the source
Reader source = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );

//optionally read in the DSL (if you are using it).
Reader dsl = new InputStreamReader(
DroolsTest.class.getResourceAsStream(
"/mylang.dsl" ) );

//Use package builder to build up a rule package.
//An alternative lower level class called "DrlParser" can
also be used...

PackageBuilder builder = new PackageBuilder();

//this wil parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is
for normal DRL.
//builder.addPackageFromDrl( source );

//Use the following instead of above if you are using a DSL:
builder.addPackageFromDrl( source, dsl );

//get the compiled package (which is serializable)
Package pkg = builder.getPackage();

//add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}


Even if I remove all rules from the dsl file, it still gives me the same
error:
org.drools.rule.InvalidRulePackage: 
[4] Unable to expand: m : Message( status == Message.HELLO, message :
message )
[6] Unable to expand:   System.out.println( message ); 
[7] Unable to expand:   m.setMessage( "Goodbye cruel world" );
[8] Unable to expand:   m.setStatus( Message.GOODBYE );
[9] Unable to expand:   update( m );
[5] Unable to expand: m : Message( status == Message.GOODBYE, message :
message )
[7] Unable to expand:   System.out.println( message );
[8] Unable to expand:   m.setMessage( message );
at org.drools.rule.Package.checkValidity(Package.java:424)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:361)
at com.sample.DroolsTest.readRule(DroolsTest.java:64)
at com.sample.DroolsTest.main(DroolsTest.java:21)



Anyone have an idea of what's wrong?
-- 
View this message in context:
http://www.nabble.com/Problem-with-DSL-in-Drools-4.0.3-tf4722439.html#a13501
597
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


TR : RE : [rules-users] How to dump the clas s/src generated by .drl file?

2007-10-31 Thread Lafon, olivier

Hi,


I'm currently using Jboss Rules in it's 3.0.6 version, and I can't find the 
JavaRuleClassBuilder class, is anyone have an idea to recover the generated 
class from dsl & Drl file? (So helpfull for debugging ^_^).
Thanks
Olivier 
 
 

De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Mark Proctor
Envoyé : mardi 7 août 2007 12:27
À : Rules Users List
Objet : Re: [rules-users] How to dump the class/src generated by .drl file?
 
There is no standard api for this, you would have to get your hands dirty with 
the source. Look at JavaRuleClassBuilder and you can see where to put your 
printouts.
Mark
Yang Song wrote: 
Greetings everyone,
 
Does anyone know how to dump the class generated from .drl file to disk? Or 
even better if the generated Java source file can be dumped?
 
Looking for some hints here, I got a NPE when firing the rules. However, it is 
really hard to find out why the NEP was thrown...  If I can have the dumped 
class file, then I can be disassemble it back to Java code.
 
To debug this rule in Eclipse is a bit difficult here, because the project is a 
little "big" and we usually use logging to do debugging...
 
java.lang.NullPointerException
at 
monitor.Rule_ftp_other_host_alarm_0.consequence(Rule_ftp_other_host_alarm_0.java:23)
at 
monitor.Rule_ftp_other_host_alarm_0ConsequenceInvoker.evaluate(Rule_ftp_other_host_alarm_0ConsequenceInvoker.java:26)
 
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
at org.drools.common.AbstractWorkingMemory.fireAllRules 
(AbstractWorkingMemory.java:430)
at 
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
at 
com.monitor.ruleengine.InferenceMachine.fireAllRules(InferenceMachine.java:400) 
at 
com.monitor.ruleengine.InferenceMachine.run(InferenceMachine.java:314)
at java.lang.Thread.run(Thread.java:595)
 
Thanks very much,
Yang
 



 
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
  
 
 


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.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Problem with DSL in Drools 4.0.3

2007-10-31 Thread tansey

I'm new to Drools, and I've setup the latest version of it in Eclipse 3.2.
I'm having trouble whenever I try to use a DSL though.  I took the standard
Hello World example and added the 'mylang.dsl' file, and changed the lines
in DroolsTest.readRule() as follows:

private static RuleBase readRule() throws Exception {
//read in the source
Reader source = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );

//optionally read in the DSL (if you are using it).
Reader dsl = new InputStreamReader( 
DroolsTest.class.getResourceAsStream(
"/mylang.dsl" ) );

//Use package builder to build up a rule package.
//An alternative lower level class called "DrlParser" can also 
be used...

PackageBuilder builder = new PackageBuilder();

//this wil parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for 
normal DRL.
//builder.addPackageFromDrl( source );

//Use the following instead of above if you are using a DSL:
builder.addPackageFromDrl( source, dsl );

//get the compiled package (which is serializable)
Package pkg = builder.getPackage();

//add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}


Even if I remove all rules from the dsl file, it still gives me the same
error:
org.drools.rule.InvalidRulePackage: 
[4] Unable to expand: m : Message( status == Message.HELLO, message :
message )
[6] Unable to expand:   System.out.println( message ); 
[7] Unable to expand:   m.setMessage( "Goodbye cruel world" );
[8] Unable to expand:   m.setStatus( Message.GOODBYE );
[9] Unable to expand:   update( m );
[5] Unable to expand: m : Message( status == Message.GOODBYE, message :
message )
[7] Unable to expand:   System.out.println( message );
[8] Unable to expand:   m.setMessage( message );
at org.drools.rule.Package.checkValidity(Package.java:424)
at 
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:361)
at com.sample.DroolsTest.readRule(DroolsTest.java:64)
at com.sample.DroolsTest.main(DroolsTest.java:21)



Anyone have an idea of what's wrong?
-- 
View this message in context: 
http://www.nabble.com/Problem-with-DSL-in-Drools-4.0.3-tf4722439.html#a13501597
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users