You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pratt <th...@gmail.com> on 2010/03/23 19:12:19 UTC

Weird behavior in getText()

I'm seeing some weird behavior in ActionSupport.getText() that is causing me
some problems in Struts 2.0.14.  From the docs (and my previous experience),
getText() retrieves entries from the resource bundle's associated with the
application.  But for some reason, in my current instance it's trying to
evaluate the resource bundle key as an OGNL expression.  Am I doing
something wrong?

In my application.properties file I have:

chart.netFrameSales.title=Net Frame Sales

In my ChartNetFrameSalesAction I have:

  public JFreeChart getChart () {
    String title = getText("chart.netFrameSales.title");

which is causing infinite recursion because OGNL is seeing the "chart." and
going to the value stack, calling getChart() and round and round we go.

The Relevant part of the stack trace shows:

[2010-03-23 11:10:47,307] WARN  {abcOu3jlPU3Rf_9tFPSzs}
OgnlValueStack.logLookupFailure: Caught an exception while evaluating
expression 'chart' against value stack
Caught an Ognl exception while getting property chart - Class:
ognl.OgnlRuntime
File: OgnlRuntime.java
Method: getMethodValue
Line: 1416 - ognl/OgnlRuntime.java:1416:-1
    at
com.opensymphony.xwork2.util.CompoundRootAccessor.getProperty(CompoundRootAccessor.java:106)
    at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2210)
    at ognl.ASTProperty.getValueBody(ASTProperty.java:114)
    at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at ognl.SimpleNode.getValue(SimpleNode.java:258)
    at ognl.Ognl.getValue(Ognl.java:494)
    at ognl.Ognl.getValue(Ognl.java:458)
    at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190)
    at
com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:228)
    at
com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:431)
    at
com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:293)
    at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:173)
    at
com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:88)
    at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:71)
    at
com.vsp.global.controller.ChartNetFrameSalesAction.getChart(ChartNetFrameSalesAction.java:84)


Is this a misconfiguration on my part, or bad documentation around the
ActionSupport.getText() method?
  (*Chris*)

RE: Weird behavior in getText()

Posted by adam pinder <ap...@hotmail.co.uk>.
 
the only thing i have different is a space before and after the = in the resource file
 
apart from that i'm using getText as you are.
 
adam


----------------------------------------
> Date: Tue, 23 Mar 2010 11:12:19 -0700
> Subject: Weird behavior in getText()
> From: thechrispratt@gmail.com
> To: user@struts.apache.org
>
> I'm seeing some weird behavior in ActionSupport.getText() that is causing me
> some problems in Struts 2.0.14. From the docs (and my previous experience),
> getText() retrieves entries from the resource bundle's associated with the
> application. But for some reason, in my current instance it's trying to
> evaluate the resource bundle key as an OGNL expression. Am I doing
> something wrong?
>
> In my application.properties file I have:
>
> chart.netFrameSales.title=Net Frame Sales
>
> In my ChartNetFrameSalesAction I have:
>
> public JFreeChart getChart () {
> String title = getText("chart.netFrameSales.title");
>
> which is causing infinite recursion because OGNL is seeing the "chart." and
> going to the value stack, calling getChart() and round and round we go.
>
> The Relevant part of the stack trace shows:
>
> [2010-03-23 11:10:47,307] WARN {abcOu3jlPU3Rf_9tFPSzs}
> OgnlValueStack.logLookupFailure: Caught an exception while evaluating
> expression 'chart' against value stack
> Caught an Ognl exception while getting property chart - Class:
> ognl.OgnlRuntime
> File: OgnlRuntime.java
> Method: getMethodValue
> Line: 1416 - ognl/OgnlRuntime.java:1416:-1
> at
> com.opensymphony.xwork2.util.CompoundRootAccessor.getProperty(CompoundRootAccessor.java:106)
> at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2210)
> at ognl.ASTProperty.getValueBody(ASTProperty.java:114)
> at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
> at ognl.SimpleNode.getValue(SimpleNode.java:258)
> at ognl.Ognl.getValue(Ognl.java:494)
> at ognl.Ognl.getValue(Ognl.java:458)
> at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:190)
> at
> com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.java:228)
> at
> com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:431)
> at
> com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:293)
> at
> com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:173)
> at
> com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:88)
> at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:71)
> at
> com.vsp.global.controller.ChartNetFrameSalesAction.getChart(ChartNetFrameSalesAction.java:84)
>
>
> Is this a misconfiguration on my part, or bad documentation around the
> ActionSupport.getText() method?
> (*Chris*) 		 	   		  
_________________________________________________________________
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Weird behavior in getText()

Posted by Dale Newfield <da...@newfield.org>.
Chris Pratt wrote:
> for some reason, in my current instance it's trying to
> evaluate the resource bundle key as an OGNL expression.

A couple weeks ago I finally took the time to look at lots of the 
warning output in my log files and was able to use that to fix a few 
buggy ognl expressions (yay for no-longer-silent failure!).  Many of the 
warnings I was unable to address (and didn't have time then to dig 
deeply enough to understand) were strings I expected to be used as 
resource bundle keys, but were instead being evaluated as OGNL.

So I don't have any insight or answers, but can confirm that this is 
indeed happening.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org