Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E8125BEBE for ; Mon, 16 Jan 2012 09:24:12 +0000 (UTC) Received: (qmail 55917 invoked by uid 500); 16 Jan 2012 09:24:11 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 54520 invoked by uid 500); 16 Jan 2012 09:24:05 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 54443 invoked by uid 99); 16 Jan 2012 09:24:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jan 2012 09:24:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jan 2012 09:24:01 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id AC8B614FED8 for ; Mon, 16 Jan 2012 09:23:41 +0000 (UTC) Date: Mon, 16 Jan 2012 09:23:41 +0000 (UTC) From: "Henri Biestro (Resolved) (JIRA)" To: issues@commons.apache.org Message-ID: <889363602.44097.1326705821726.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1515777697.42967.1326653619504.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (JEXL-125) Unable to invoke method with ObjectContext MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JEXL-125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Henri Biestro resolved JEXL-125. -------------------------------- Resolution: Not A Problem Not an issue, however ObjectContext should expose the wrapped object as 'protected' (will do in 3.0). > Unable to invoke method with ObjectContext > ------------------------------------------ > > Key: JEXL-125 > URL: https://issues.apache.org/jira/browse/JEXL-125 > Project: Commons JEXL > Issue Type: Bug > Affects Versions: 2.1.1 > Environment: Java 1.6.0_20 on Windows 7 > Reporter: Matteo Trotta > Assignee: Henri Biestro > > Hi, I'm trying to invoke a method on Object context but I can't get it to work. > I don't know if it's a bug or I'm doing it wrong. > Here it is the code I'm using: > {code:title=JexlTest.java} > package it.test; > import org.apache.commons.jexl2.Expression; > import org.apache.commons.jexl2.JexlContext; > import org.apache.commons.jexl2.JexlEngine; > import org.apache.commons.jexl2.ObjectContext; > import org.junit.Test; > public class JexlTest { > public static class Foo { > public String method() { > return "OK"; > } > } > @Test > public void test() throws Exception { > JexlEngine jexl = new JexlEngine(); > jexl.setStrict(true); > Expression e = jexl.createExpression("method()"); > JexlContext jc = new ObjectContext(jexl, new Foo()); > System.out.println(e.evaluate(jc)); > } > } > {code} > Here is the exception I'm getting: > {noformat} > org.apache.commons.jexl2.JexlException: it.test.JexlTest.test@19![0,8]: 'method();' method error > at org.apache.commons.jexl2.Interpreter.call(Interpreter.java:1078) > at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:1100) > at org.apache.commons.jexl2.parser.ASTMethodNode.jjtAccept(ASTMethodNode.java:18) > at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:1317) > at org.apache.commons.jexl2.parser.ASTReference.jjtAccept(ASTReference.java:18) > at org.apache.commons.jexl2.Interpreter.interpret(Interpreter.java:232) > at org.apache.commons.jexl2.ExpressionImpl.evaluate(ExpressionImpl.java:65) > at it.test.JexlTest.test(JexlTest.java:21) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) > at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) > at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) > at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:274) > at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) > at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:242) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:58) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:240) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:48) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:233) > at org.junit.runners.ParentRunner.run(ParentRunner.java:303) > at org.junit.runner.JUnitCore.run(JUnitCore.java:157) > at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) > at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) > at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) > Caused by: org.apache.commons.jexl2.JexlException$Property: org.apache.commons.jexl2.ObjectContext.get@42![0,9]: '#0.method;' inaccessible or unknown property #0 > at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:1341) > at org.apache.commons.jexl2.parser.ASTReference.jjtAccept(ASTReference.java:18) > at org.apache.commons.jexl2.JexlEngine.getProperty(JexlEngine.java:615) > at org.apache.commons.jexl2.JexlEngine.getProperty(JexlEngine.java:587) > at org.apache.commons.jexl2.ObjectContext.get(ObjectContext.java:42) > at org.apache.commons.jexl2.Interpreter.call(Interpreter.java:1047) > {noformat} > Using a MapContext with variable "foo" set to 'new Foo()' and the expression "foo.method()" gives no error. > Anyway for my use it's more practical a ObjectContext, as I have only one object in the context. > Thank you for very much and keep up the excellent work! > Matteo Trotta -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira