Hi all,
I am getting the same problem reported by vladperl. I've got rules and
rulesflows using MVEL2 scripts that work fine in Windows running in JBoss
and junit tests. I've inserted a map into StatefulKnowledgeSession and I am
successfully invoking myMap.myObject.myValue without any casting. However I
am now deploying the application in RedHat with Websphere 7 and I am getting
everywhere errors like:
unqualified type in strict mode for: myObject
unqualified type in strict mode for: myValue
unable to resolve method using strict-mode:
java.lang.Object.get(java.lang.String)]
It seems that somehow the MVEL's Strong Typing Mode has been setup in this
env. This doesn't make sense to me. I rather prefer to believe the error is
misleading and something else is bothering MVEL when parsing my rules and
ruleflow files.
Any help will be much appreciated!
vladperl wrote:
Hi Wolfgang,
Please take a look at attached new example.
This time the example can demonstrate when strict mode is false we don't
have to put class cast.
Beside I finally figured out how to switch strict mode for MVEL dialect.
Best regards,
Vladimir
Date: Sat, 3 Oct 2009 14:36:10 +0200
From: wolfgang.laun(a)gmail.com
To: rules-users(a)lists.jboss.org
Subject: Re: [rules-users] unable to resolve method using strict-mode
The Java code in the archive just compiles a .drl file, and there's no
reason this should fail. The class cast would only appear to be missing
after a Map object is inserted into WM, and the session is run so that the
rule fires.
-W
2009/10/2 Vladimir Perlov <vladperl(a)hotmail.com>
It's compiled and working on Windows without any casting :)
Check out the test project I attached.
You will see that the rule will compile from web application (Windows
only) or with Java SE application. The web application using JSF so in
case to run it use application server with included JSF library.
http://download.java.net/glassfish/v3/promoted/
Date: Fri, 2 Oct 2009 19:48:17 +0200
From: wolfgang.laun(a)gmail.com
To: rules-users(a)lists.jboss.org
Subject: Re: [rules-users] unable to resolve method using strict-mode
Map() in the .drl file is bound to be interpreted as Map<Object,Object> so
that a Map.get() returns an Object. To be able to call method
getSomeMethod() you'd have to cast this result, according to
((SomeClass)$map.get("x")).getSomeMethod()
I fail to understand how this could ever be avoided - strict or no strict,
MVEL or not MVEL.
-W
2009/10/2 Vladimir Perlov <vladperl(a)hotmail.com>
Hi Wolfgang,
Thank you very much for quick response!
I tried your suggestion and still getting the following error:
Unable to build expression for 'consequence': Failed to compile: 1
compilation error(s): - (1,29) unable to resolve method using
strict-mode: java.lang.Object.getSomeMethod() '
System.out.println($map.get("x").getSomeMethod());
' : [Rule name='TEST']
At least now I have only 1 compilation error comparing to the previous
variant.
modified rule:
rule "TEST"
dialect "mvel"
when
$map : Map()
then
System.out.println($map.get("x").getSomeMethod());
end
I believe that problem is related to strict-mode that somehow enforced on
Linux but not on Windows.
I tried to remove the strict mode using the the following approach but it
seems don't have any effect.
We have web application with many drools rules and it's working on Windows
but when we deployed the same application to Linux we are getting failed
compile errors ;)
KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
config.setProperty("drools.dialect.mvel.strict", "false");
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);
Please advise me.
By the way I'm using drools 5.0.1
Date: Fri, 2 Oct 2009 18:30:25 +0200
From: wolfgang.laun(a)gmail.com
To: rules-users(a)lists.jboss.org
Subject: Re: [rules-users] unable to resolve method using strict-mode
2009/10/2 Vladimir Perlov <vladperl(a)hotmail.com>
Here is the rule that failed to compile on Linux:
rule "TEST"
dialect "mvel"
Send
when
map : Map()
$map : Map()
or omit '$' in the consequence.
-W
then
System.out.println($map.get("x").getSomeMethod());
end
Lauren found her dream laptop. Find the PC that’s right for you.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Hotmail® has ever-growing storage! Don’t worry about storage limits. Check
it out.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users