aspose file tools*
The moose likes Struts and the fly likes Struts2 :: ognl.ParseException for special request parameters starting with a . (dot) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 :: ognl.ParseException for special request parameters starting with a . (dot)" Watch "Struts2 :: ognl.ParseException for special request parameters starting with a . (dot)" New topic
Author

Struts2 :: ognl.ParseException for special request parameters starting with a . (dot)

Sam Rakshit
Greenhorn

Joined: Jun 22, 2010
Posts: 8
Hi,

I am integrating a Yahoo Blueprint application with Struts2 and I end up getting the error

ognl.ParseException: Encountered " "." ". "" at line 1, column 1.

when this URL is called : http://mydomain.bpapps.com/public/login?.ts=1277027581&.intl=IN&.lang=en-in

I cannot modify the way the URL is set as this comes from the Yahoo Servers. What I can try is to configure Struts2 to ignore the parameters starting with .intl, .lang, .ts. But again, I will also need a way to access these parameters from my source code.

Can anyone help me with this? How do I solve this problem?

The complete stack trace of the exception follows :

com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn: Error setting expression '.intl' with value '[Ljava.lang.String;@83fde6'
ognl.ExpressionSyntaxException: Malformed OGNL expression: .intl [ognl.ParseException: Encountered " "." ". "" at line 1, column 1.
Was expecting one of:
":" ...
"not" ...
"+" ...
"-" ...
"~" ...
"!" ...
"(" ...
"true" ...
"false" ...
"null" ...
"#this" ...
"#root" ...
"#" ...
"[" ...
"{" ...
"@" ...
"new" ...
<IDENT> ...
<DYNAMIC_SUBSCRIPT> ...
"\'" ...
"`" ...
"\"" ...
<INT_LITERAL> ...
<FLT_LITERAL> ...
]
at ognl.Ognl.parseExpression(Ognl.java:112)
at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:214)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:250)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5838)
at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5836)
at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24)
at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:398)
at com.google.net.rpc.impl.Server$2.run(Server.java:852)
at com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56)
at com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan(LocalTraceSpanBuilder.java:576)
at com.google.net.rpc.impl.Server.startRpc(Server.java:807)
at com.google.net.rpc.impl.Server.processRequest(Server.java:369)
at com.google.net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:442)
at com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:319)
at com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:290)
at com.google.net.async.Connection.handleReadEvent(Connection.java:474)
at com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:831)
at com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:207)
at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:103)
at com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:251)
at com.google.apphosting.runtime.JavaRuntime$RpcRunnable.run(JavaRuntime.java:413)
at java.lang.Thread.run(Unknown Source)
Caused by: ognl.ParseException: Encountered " "." ". "" at line 1, column 1.
Was expecting one of:
":" ...
"not" ...
"+" ...
"-" ...
"~" ...
"!" ...
"(" ...
"true" ...
"false" ...
"null" .
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

My first thought would be to modify the parameter names in a filter or interceptor--if you're not using these kinds of parameters across the application, an action-specific interceptor might be the cleanest solution. Or just don't process it with Struts--map it to a servlet instead (which could do whatever it needs to, and/or muck with the parameter names, and potentially forward to an action).

But yes--since S2 (and similar) frameworks will try to map parameter names to actual objects, things like this will cause a problem.
Sam Rakshit
Greenhorn

Joined: Jun 22, 2010
Posts: 8
David Newton wrote:My first thought would be to modify the parameter names in a filter or interceptor--if you're not using these kinds of parameters across the application, an action-specific interceptor might be the cleanest solution. Or just don't process it with Struts--map it to a servlet instead (which could do whatever it needs to, and/or muck with the parameter names, and potentially forward to an action).

But yes--since S2 (and similar) frameworks will try to map parameter names to actual objects, things like this will cause a problem.


Pardon me for my ignorance as I am very new in Struts2. But will the interceptors be invoked even before the request parameters are parsed and set into the value stack? Also, can I use or override an existing interceptor like ParameterInterceptor for this?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sam Rakshit wrote:Pardon me for my ignorance as I am very new in Struts2. But will the interceptors be invoked even before the request parameters are parsed and set into the value stack? Also, can I use or override an existing interceptor like ParameterInterceptor for this?

Depends on where you put the interceptor in the stack. And yes, you *could*, but I'm not really sure you'd gain much by doing so.

You might actually be able to use the parameter mapping interceptor (I forget its name at the moment) to do the mapping, but it may have the same problem--I'd imagine it treats the names as object references at well. Making a parameter *name* filter interceptor would be pretty easy, though.
Sam Rakshit
Greenhorn

Joined: Jun 22, 2010
Posts: 8
Finally after following your advice, and the steps mentioned in this link - http://www.oracle.com/technology/pub/articles/dev2arch/2005/05/decorators.html

I created a servlet filter and overridden the getParameterMap() directly even before struts could start processing the request. I iterate through the keys and check of a .(dot) and remove it and populate another map with the parameter values and the sanitized keys. This is working for me now.

I hope this is a full proof solution. Please comment.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Seems reasonable to me--I'm sure there are other solutions, but this is easy, and sounds like it works :)
Nancy James
Greenhorn

Joined: Oct 23, 2014
Posts: 6
Sam Rakshit wrote:Finally after following your advice, and the steps mentioned in this link - http://www.oracle.com/technology/pub/articles/dev2arch/2005/05/decorators.html

I created a servlet filter and overridden the getParameterMap() directly even before struts could start processing the request. I iterate through the keys and check of a .(dot) and remove it and populate another map with the parameter values and the sanitized keys. This is working for me now.

I hope this is a full proof solution. Please comment.


"Hi am facing the same problem and tried to access the link " http://www.oracle.com/technology/pub/articles/dev2arch/2005/05/decorators.html" but its not working.
Please help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 :: ognl.ParseException for special request parameters starting with a . (dot)