Class Cast Exception
by Robert Morse
This has come up before, but I think my circumstances may be different.
I'm using Seam 2.0.0.CR2, Drool 4.0.3, and JBoss AS 4.2.1 along with
all of the relevant support jars.
I have a Java Application that uses the JBoss server for entity beans,
etc. It uses Drools PackageBuilder, loads the drl file and fires the
rules without any problems.
I'm now moving that same functionality to a stateful Seam bean. When
a user clicks on a button, I invoke an action which executes the same
code as in the stand alone java application. However, when it
attempts to create a new PackageBuilder via new PackageBuilder() it
throws:
18:05:18,610 ERROR [STDERR] org.drools.RuntimeDroolsException: Unable
to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
followed by:
18:05:18,621 ERROR [STDERR] Caused by: java.lang.ClassCastException:
org.drools.rule.builder.dialect.java.JavaDialectConfiguration
18:05:18,621 ERROR [STDERR] at
org
.drools
.compiler
.PackageBuilderConfiguration
.addDialect(PackageBuilderConfiguration.java:147)
I've seen this posted several times, and the suggested cause is
missing jars in the classpath. However, I have all of the 4.0.3
Drools jars, mvel14, and jdt-core jars in place.
Obviously, it's some configuration problem since I have the exact
thing working as a java application.
Any suggestions?
Thanks.
17 years, 1 month
Executing rules actions asynchronously
by 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.
17 years, 1 month
Re: [rules-users] Accessing maps (hashmaps) keys and values in rules
by shaz
Hi,
I am placing objects in the Hashmap that were retrieved from the database. There are currently a hundred objects that I'm storing in the HashMap. I just made a simple example earlier :) . What works for me now is putting the getting of the values in the eval(). However, I don't know how to assign the values that I've taken from the Map.
eval( ( (MyClass)mapOfObj.get("keyOfObj")).getId() > 30);
How do I assign (MyClass)mapOfObj.get("keyOfObj") to a variable?
tnx,
shaz
----- Original Message ----
From: "Anstis, Michael (M.)" <manstis1(a)ford.com>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Friday, November 2, 2007 12:17:51 AM
Subject: RE: [rules-users] Accessing maps (hashmaps) keys and values in rules
By way of example (if you misunderstand how the rule engine
should be used):-
rule
chkobj
when
$o :
MyClass( id == "1", name == "name"
)
then
//Do
something else
$o.doSomething();
end
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson
Tirelli
Sent: 01 November 2007 15:48
To: Rules Users
List
Subject: Re: [rules-users] Accessing maps (hashmaps) keys and
values in rules
Shaz,
We strongly advise you
to move to 4.0.3, but this is not related to your problem.
I
think you are misunderstanding something. Why are you using the global map to
store your fact? Simply insert it into the working memory and it will work
fine.
[]s
Edson
2007/11/1, Shaz Tumulak <shauii(a)yahoo.com>:
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<String, MyClass>
mapOfObj = new TreeMap<String, MyClass>();
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 ==
"99999999" )
> 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) <dennisryan(a)avaya.com
>:
>>
>> 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(a)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(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
shauii(a)yahoo.com
--
View this
message in context: http://www.nabble.com/Accessing-maps-%28hashmaps%29-keys-and-values-in-ru...
Sent from the drools - user mailing list archive at Nabble.com.
_______________________________________________
rules-users
mailing list
rules-users(a)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
____________________________________________________
Organic foods - just how healthy is health food?
Be a better foodie
Find out at Yahoo! Answers - http://ph.answers.yahoo.com/
17 years, 1 month
Reusable jBRMS APIs
by Chong Minsk Goh
Hi,
Is anyone familiar with the source codes of the jbrms? Could anyone
kindly help me pin point what are the exact APIs/packages for:
Translating the user inputs into DRL file (parsers?)
Validating/Compiling/Packaging the DRL file
Cheers!
Chong Minsk
17 years, 1 month
Using java.util.List in rules
by Anderson Pazza Mello
Hi everyone,
I'm trying to use a java.util.List like this:
rule "Test"
when
e : Especialista(retratoUser.lstCarac.get(0).codCarac != 0)
then
System.out.println("test");
end
The property lstCarac is a java.util.List<Caracteristica>. I'm getting this
error :
org.drools.rule.InvalidRulePackage: [18,44]: unknown:18:44 Unexpected token
'0'[18,46]: unknown:18:46 Unexpected token '.'
at org.drools.rule.Package.checkValidity(Package.java:419)
Someone knows what i have to do to fix the problem??
--
Anderson Pazza Mello
Tecnologia em Informática - UFPR
17 years, 1 month
Handler Conflict Warning Eclipse 3.3 with 4.03
by J Michael Dean
Starting afresh with Eclipse and encounter a message that a handler
conflict occurred. The conflict relates to the
ConvertToDroolsProjectAction. This is with a fresh install and no
workspace. I can create a rules project and it functions correctly.
The trace is below. Is this a problem or just completely ignorable?
!SESSION 2007-11-01 05:38:01.559
-----------------------------------------------
eclipse.buildId=M20070921-1145
java.version=1.5.0_13
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=ppc, WS=carbon, NL=en_US
Framework arguments: -keyring /Users/mdean/.eclipse_keyring -
showlocation
Command-line arguments: -os macosx -ws carbon -arch ppc -keyring /
Users/mdean/.eclipse_keyring -consoleLog -showlocation
!ENTRY org.eclipse.ui.workbench 2 0 2007-11-01 05:38:23.036
!MESSAGE A handler conflict occurred. This may disable some commands.
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2007-11-01 05:38:23.036
!MESSAGE Conflict for
'org.drools.eclipse.action.ConvertToDroolsProjectAction':
HandlerActivation
(commandId=org.drools.eclipse.action.ConvertToDroolsProjectAction,
handler
=
ActionDelegateHandlerProxy
(null,org.drools.eclipse.action.ConvertToDroolsProjectAction),
expression
=
WorkbenchWindowExpression
(org.eclipse.ui.internal.WorkbenchWindow@4613f1),sourcePriority=16384)
HandlerActivation
(commandId=org.drools.eclipse.action.ConvertToDroolsProjectAction,
handler
=
ActionDelegateHandlerProxy
(null,org.drools.eclipse.action.ConvertToDroolsProjectAction),
expression
=
WorkbenchWindowExpression
(org.eclipse.ui.internal.WorkbenchWindow@4613f1),sourcePriority=16384)
17 years, 2 months
Problem with DSL in Drools 4.0.3
by 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#a13...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 2 months