struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Greene (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4138) OgnlTextParser contains a NPE when the expression is passed in as null
Date Fri, 12 Jul 2013 14:13:49 GMT

    [ https://issues.apache.org/jira/browse/WW-4138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13706966#comment-13706966
] 

David Greene commented on WW-4138:
----------------------------------

{code}
19:19:23,603 ERROR [freemarker.runtime] (http--0.0.0.0-8443-3) Template processing error:
"Method public java.util.List org.apache.struts2.components.Form.getValidators(java.lang.String)
threw an exception when invoked on org.apache.struts2.components.Form@7b510a00": freemarker.template.TemplateModelException:
Method public java.util.List org.apache.struts2.components.Form.getValidators(java.lang.String)
threw an exception when invoked on org.apache.struts2.components.Form@7b510a00
	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130) [freemarker.jar:2.3.19]
	at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93) [freemarker.jar:2.3.19]
	at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) [freemarker.jar:2.3.19]
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:428) [freemarker.jar:2.3.19]
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.MixedContent.accept(MixedContent.java:92) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.MixedContent.accept(MixedContent.java:92) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.include(Environment.java:1508) [freemarker.jar:2.3.19]
	at freemarker.core.Include.accept(Include.java:169) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.MixedContent.accept(MixedContent.java:92) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.process(Environment.java:199) [freemarker.jar:2.3.19]
	at freemarker.template.Template.process(Template.java:259) [freemarker.jar:2.3.19]
	at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:157)
[struts2-core.jar:2.3.15]
	at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:572) [struts2-core.jar:2.3.15]
	at org.apache.struts2.components.UIBean.end(UIBean.java:526) [struts2-core.jar:2.3.15]
	at org.apache.struts2.views.freemarker.tags.CallbackWriter.afterBody(CallbackWriter.java:84)
[struts2-core.jar:2.3.15]
	at freemarker.core.Environment.visit(Environment.java:312) [freemarker.jar:2.3.19]
	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.MixedContent.accept(MixedContent.java:92) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.IfBlock.accept(IfBlock.java:82) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.MixedContent.accept(MixedContent.java:92) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.include(Environment.java:1508) [freemarker.jar:2.3.19]
	at freemarker.core.Include.accept(Include.java:169) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.MixedContent.accept(MixedContent.java:92) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.visit(Environment.java:221) [freemarker.jar:2.3.19]
	at freemarker.core.Environment.process(Environment.java:199) [freemarker.jar:2.3.19]
	at freemarker.template.Template.process(Template.java:259) [freemarker.jar:2.3.19]
	at org.apache.struts2.views.freemarker.FreemarkerResult.doExecute(FreemarkerResult.java:215)
[struts2-core.jar:2.3.15]
	at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
[struts2-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
[xwork-core.jar:2.3.15]
	at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) [struts2-core.jar:2.3.15]
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563) [struts2-core.jar:2.3.15]
	at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
[struts2-core.jar:2.3.15]
	at org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:93)
[struts2-core.jar:2.3.15]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
	at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
[sitemesh.jar:]
	at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) [sitemesh.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:91)
[struts2-core.jar:2.3.15]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
	at rss.web.filter.SignOnFilter.doFilter(SignOnFilter.java:312) [classes:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
	at rss.web.filter.SkinFilter.doFilter(SkinFilter.java:110) [classes:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
	at rss.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:129)
[classes:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.13.Final.jar:]
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
Caused by: java.lang.NullPointerException
	at com.opensymphony.xwork2.util.OgnlTextParser.evaluate(OgnlTextParser.java:33) [classes:2.3.15]
	at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:170)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:113)
[xwork-core.jar:2.3.15]
	at com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:86) [xwork-core.jar:2.3.15]
	at org.apache.struts2.components.Component.findValue(Component.java:353) [struts2-core.jar:2.3.15]
	at org.apache.struts2.components.Component.findString(Component.java:203) [struts2-core.jar:2.3.15]
	at org.apache.struts2.components.Form.getValidators(Form.java:276) [struts2-core.jar:2.3.15]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.7.0_17]
	at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]
	at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:866) [freemarker.jar:2.3.19]
	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106) [freemarker.jar:2.3.19]
	... 120 more
{code}
                
> OgnlTextParser contains a NPE when the expression is passed in as null
> ----------------------------------------------------------------------
>
>                 Key: WW-4138
>                 URL: https://issues.apache.org/jira/browse/WW-4138
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.3.15
>            Reporter: David Greene
>             Fix For: 2.3.16
>
>
> Unfortunately, I haven't figured out the exact cause of the issue; however, the fix provided
brings our system back to how it used to work.
> When expression is passed in a null, a NPE is thrown @:
> int start = expression.indexOf(lookupChars, pos);
> {code}
>         Object result = expression;
>         int pos = 0;
>         for (char open : openChars) {
>             int loopCount = 1;
>             //this creates an implicit StringBuffer and shouldn't be used in the inner
loop
>             final String lookupChars = open + "{";
>             while (true) {
>                 int start = expression.indexOf(lookupChars, pos);
>                 if (start == -1) {
>                     loopCount++;
>                     start = expression.indexOf(lookupChars);
>                 }
> {code}
> Here is the fix I'm using in a locally built class file:
> {code}
>         Object result = expression = (expression == null) ? "" : expression;
>         int pos = 0;
>         for (char open : openChars) {
>             int loopCount = 1;
>             //this creates an implicit StringBuffer and shouldn't be used in the inner
loop
>             final String lookupChars = open + "{";
>             while (true) {
>                 int start = expression.indexOf(lookupChars, pos);
>                 if (start == -1) {
>                     loopCount++;
>                     start = expression.indexOf(lookupChars);
>                 }
> {code}
> I can see about 10 different ways to 'fix' the issue, but this keeps the change to a
single line since I don't entirely understand the workflow of what's going on.
> FYI, it seems to have something to do with validate="true" on the form and when there
are fields to validate which have nested getters, aka:
> <@s.hidden key="myFakePatternHolder.pattern.id"/>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message