Bug 769587 - drools modify command mvel exception
Summary: drools modify command mvel exception
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.3.0.GA
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ER7
: ---
Assignee: Mario Fusco
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-12-21 11:55 UTC by Radovan Synek
Modified: 2023-05-31 22:25 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
When trying to execute the MVEL modify command on a stateful session an exception occurs (unable to resolve method). This was caused by a omission in the following line: sbuilder.append( setter.getAccessor() + " = " + setter.getValue() + "\n" ); which should have been: sbuilder.append( setter.getAccessor() + " = '" + setter.getValue() + "'\n" );. The error has been corrected and the issue no longer occurs.
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)
modify command reproducer - maven project (5.89 KB, application/zip)
2011-12-21 11:55 UTC, Radovan Synek
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBRULES-3377 0 Major Resolved drools modify command mvel exception 2013-03-19 00:30:14 UTC

Description Radovan Synek 2011-12-21 11:55:51 UTC
Created attachment 549016 [details]
modify command reproducer - maven project

Following exception occurs when trying to execute modify command on stateful session:

{ with (this) {
age = 30
,name = Frank
,id = 0
,likes = nobody
} }
Exception in thread "main" [Error: unable to resolve method: com.redhat.modifyreproducer.Person.Frank() [arglength=0]]
[Near : {... ,name = Frank ....}]
             ^
[Line: 5, Column: 1]
	at org.mvel2.PropertyAccessor.getMethod(PropertyAccessor.java:977)
	at org.mvel2.PropertyAccessor.getBeanProperty(PropertyAccessor.java:687)
	at org.mvel2.PropertyAccessor.getNormal(PropertyAccessor.java:202)
	at org.mvel2.PropertyAccessor.get(PropertyAccessor.java:171)
	at org.mvel2.PropertyAccessor.get(PropertyAccessor.java:151)
	at org.mvel2.ast.ASTNode.getReducedValue(ASTNode.java:185)
	at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:106)
	at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:49)
	at org.mvel2.MVEL.eval(MVEL.java:408)
	at org.mvel2.util.ParseTools.parseWithExpressions(ParseTools.java:1591)
	at org.mvel2.ast.WithNode.getReducedValue(WithNode.java:75)
	at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:106)
	at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:49)
	at org.mvel2.MVEL.eval(MVEL.java:109)
	at org.drools.command.runtime.rule.ModifyCommand.execute(ModifyCommand.java:79)
	at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:798)
	at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:781)
	at com.redhat.modifyreproducer.Main.test(Main.java:52)
	at com.redhat.modifyreproducer.Main.main(Main.java:30)

------------------------------------------------------------------------------
First, fact is inserted into the session, next step is creating Modify command with setter list:

Person p1 = new Person("John", "nobody", 25);
        session.execute(CommandFactory.newInsert(p1));
        FactHandle fh = session.getFactHandle(p1);
        
        Person p = new Person("Frank", "nobody", 30);
        List<Setter> setterList = new ArrayList<Setter>();
        setterList.add(CommandFactory.newSetter("age", String.valueOf(p.getAge())));
        setterList.add(CommandFactory.newSetter("name", p.getName()));
        setterList.add(CommandFactory.newSetter("likes", p.getLikes()));
        setterList.add(CommandFactory.newSetter("id", String.valueOf(p.getId())));
            
        session.execute(CommandFactory.newModify(fh, setterList)); 

See an attachment for the details, just build as maven project and run.

Comment 3 JBoss JIRA Server 2012-02-06 10:42:48 UTC
Mario Fusco <mario.fusco> updated the status of jira JBRULES-3377 to Resolved

Comment 4 Ryan Zhang 2012-02-15 09:12:49 UTC
Please verify the issue on 5.3 ER4.

Comment 5 Radovan Synek 2012-02-27 13:23:42 UTC
Problem still occurs, the same exception.

Comment 6 Radovan Synek 2012-02-28 08:12:26 UTC
Pull request with reproducer:
https://github.com/droolsjbpm/drools/pull/104

Comment 7 Mario Fusco 2012-03-01 15:52:08 UTC
The fix has been backported to the 5.3.x by upgrading the mvel version in use.

Comment 8 Lukáš Petrovický 2012-03-20 17:26:54 UTC
Comment 7 suggests that this has been fixed a while ago. Moving to ON_QA.

Comment 9 Radovan Synek 2012-03-22 14:35:34 UTC
Looks like this issue is resolved on master (mvel2-2.1.0.drools10.jar), but not on 5.3.x (mvel2-2.1.0.drools8.jar)

Comment 10 Mario Fusco 2012-03-26 14:21:55 UTC
I upgraded the mvel version used also by the 5.3.x, so this issue should be fixed also there.

Comment 11 Ryan Zhang 2012-04-23 07:37:19 UTC
Update status to ON_QA. Please verify them against ER6.

Comment 12 Radovan Synek 2012-04-25 08:35:09 UTC
I have tried on ER6 and there is the same exception. I am not so sure that problem is with MVEL version; the test case provided in pull request (see comment 6) works on master but fails on 5.3.x for me - although both branches use the same MVEL version.

Also I have found a difference between these two branches in method org.drools.command.runtime.rule.ModifyCommand.getMvelExpr() - which is on the exception stack trace.

master
line 115:
sbuilder.append( setter.getAccessor() + " = '" + setter.getValue() + "'\n" );

5.3.x:
line 115:
sbuilder.append( setter.getAccessor() + " = " + setter.getValue() + "\n" );

The difference is missing "'" sign on 5.3.x. Isn't it possible that this is the problem?

Comment 13 JBoss JIRA Server 2012-04-25 08:53:56 UTC
Mario Fusco <mario.fusco> made a comment on jira JBRULES-3377

Indeed I flagged 5.4.0.CR1 as the fix version for this issue, not the 5.3

Comment 14 Mario Fusco 2012-05-09 16:51:01 UTC
I just backported the fix to the 5.3

Comment 15 Ryan Zhang 2012-05-11 11:48:42 UTC
This fix has been committed to project branch which BRMS 5.3 used.

So this requires to request block+ flag or revert in the branch at current
phase.

Comment 16 Ryan Zhang 2012-05-14 08:16:43 UTC
The fixed for this issue should be included in ER7. Please do verification on it.

Comment 17 lcarlon 2012-06-01 03:13:26 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When trying to execute the MVEL modify command on a stateful session an exception occurs (unable to resolve method). This was caused by a omission in the following line: sbuilder.append( setter.getAccessor() + " = " + setter.getValue() + "\n" ); which should have been: sbuilder.append( setter.getAccessor() + " = '" + setter.getValue() + "'\n" );. The error has been corrected and the issue no longer occurs.


Note You need to log in before you can comment on or make changes to this bug.