You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Priyanka Vaddadi <Pr...@doj.ca.gov.INVALID> on 2025/05/28 05:54:17 UTC
Struts 7.0 issue with Ftl
Hi
I am getting below error while loading the page after migrating to struts 7
Pleaselet me know what could be the issue
Template inclusion failed (for parameter value "/Empty{name='templateDir'}/simple/checkbox.ftl"):
Template not found for name "Empty{name='templateDir'}/simple/checkbox.ftl".
The name was interpreted by this TemplateLoader: org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader@6ab4e90c.
----
FTL stack trace ("~" means nesting-related):
- Failed at: #include "/${parameters.templateDir}/... [in template "template/wam/checkbox.ftl" at line 23, column 1]
----
Java stack trace (for programmers):
----
freemarker.core._MiscTemplateException: [... Exception message was already printed; see it above ...]
at deployment.wam.war//freemarker.core.Include.accept(Include.java:164)
at deployment.wam.war//freemarker.core.Environment.visit(Environment.java:344)
at deployment.wam.war//freemarker.core.Environment.visit(Environment.java:350)
at deployment.wam.war//freemarker.core.Environment.process(Environment.java:323)
at deployment.wam.war//freemarker.template.Template.process(Template.java:383)
at deployment.wam.war//org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:152)
at deployment.wam.war//org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:595)
at deployment.wam.war//org.apache.struts2.components.UIBean.end(UIBean.java:554)
at deployment.wam.war//org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:36)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspx_meth_s_005fcheckbox_005f0(userRoles_jsp.java:302)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspx_meth_s_005fiterator_005f0(userRoles_jsp.java:254)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspService(userRoles_jsp.java:158)
CONFIDENTIALITY NOTICE: This communication with its contents may contain confidential and/or legally privileged information. It is solely for the use of the intended recipient(s). Unauthorized interception, review, use or disclosure is prohibited and may violate applicable laws including the Electronic Communications Privacy Act. If you are not the intended recipient, please contact the sender and destroy all copies of the communication.
Aw: Re: Setting struts.devMode only in struts.xml?
Posted by Ute Kaiser <ut...@web.de.INVALID>.
Thank you Lukasz,
Great advice and great documentation.
I guess I need some search machine on the documentation.
I edited struts.xml and added the variable to the Eclipse Wildfly Runtime (Tab Environment), and it works fine.
Best regards Ute
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Setting struts.devMode only in struts.xml?
Posted by Lukasz Lenart <lu...@apache.org>.
czw., 29 maj 2025 o 11:22 Ute Kaiser <ut...@web.de.invalid> napisał(a):
>
> I face the issue that I have to change my struts.xml any time I want to deploy from dev environment to test or production environment.
> Either struts.devMode value=true or false. This might lead to deploying devMode to production by accident.
> Is there an alternative place to set devMode more flexible?
>
> I tried:
> Eclipse (2024-09) Wildfly33 Server Launch Configuration VM arguments -Dstruts.devMode=true but no effect.
> Using ant for build.
You can use value substitution
https://struts.apache.org/core-developers/constant-configuration#value-substitution
Cheers
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Setting struts.devMode only in struts.xml?
Posted by Ute Kaiser <ut...@web.de.INVALID>.
I face the issue that I have to change my struts.xml any time I want to deploy from dev environment to test or production environment.
Either struts.devMode value=true or false. This might lead to deploying devMode to production by accident.
Is there an alternative place to set devMode more flexible?
I tried:
Eclipse (2024-09) Wildfly33 Server Launch Configuration VM arguments -Dstruts.devMode=true but no effect.
Using ant for build.
Best regards
Ute
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 7.0 issue with Ftl
Posted by Lukasz Lenart <lu...@apache.org>.
czw., 29 maj 2025 o 05:24 Priyanka Vaddadi
<Pr...@doj.ca.gov.invalid> napisał(a):
> when I replace
> <#if parameters.nameValue??>
> value="<@s.property value="parameters.nameValue"/>"<#rt/>
> </#if> with
>
> <#if attributes.name??>
> value="<@s.property value="%{attributes.name}"/>"<#rt/>
> </#if>
Why do you replace "nameValue" with "name"? These are two different
attributes, please read this section
https://struts.apache.org/tag-developers/form-tags#valuename-relationship
Cheers
Lukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Struts 7.0 issue with Ftl
Posted by Priyanka Vaddadi <Pr...@doj.ca.gov.INVALID>.
Hi
when I replace
<#if parameters.nameValue??>
value="<@s.property value="parameters.nameValue"/>"<#rt/>
</#if> with
<#if attributes.name??>
value="<@s.property value="%{attributes.name}"/>"<#rt/>
</#if>
I am getting parameter name displayed in text box but not parameter value
Please help me with this
Thank and Regards
Priyanka
From: Priyanka Vaddadi
Sent: Wednesday, May 28, 2025 6:55 AM
To: user@struts.apache.org
Subject: RE: Struts 7.0 issue with Ftl
Hi
When I change below code
<#if parameters.disabled?string?lower_case == "true">
disabled="disabled"<#rt/>
</#if> with
<#if attributes.disabled?string?lower_case == "true">
disabled="disabled"<#rt/>
</#if>
I am getting below error
FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!)
The following has evaluated to null or missing:
==> attributes.disabled [in template "template/wam/text.ftl" at line 51, column 6]
----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if attributes.disabled?string?lower_... [in template "template/wam/text.ftl" at line 51, column 1]
----
Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at deployment.wam.war//freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
at deployment.wam.war//freemarker.core.UnexpectedTypeException.newDescriptionBuilder(UnexpectedTypeException.java:85)
And how do I replace this code which is present in my ftl
<#if parameters.maxlength??>
maxlength="${parameters.maxlength}"<#rt/>
</#if>
I don't see maxLength property in attributes
And when I replace
<#if parameters.nameValue??>
value="<@s.property value="parameters.nameValue"/>"<#rt/>
</#if> with
<#if attributes.name??>
value="<@s.property value="%{attributes.name}"/>"<#rt/>
</#if>
I am getting parameter name displayed in text box but not parameter value
Please help me with this
Thanks and Regards
Priyanka
From: Priyanka Vaddadi
Sent: Tuesday, May 27, 2025 10:54 PM
To: user@struts.apache.org<ma...@struts.apache.org>
Subject: Struts 7.0 issue with Ftl
Hi
I am getting below error while loading the page after migrating to struts 7
Pleaselet me know what could be the issue
Template inclusion failed (for parameter value "/Empty{name='templateDir'}/simple/checkbox.ftl"):
Template not found for name "Empty{name='templateDir'}/simple/checkbox.ftl".
The name was interpreted by this TemplateLoader: org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader@6ab4e90c<ma...@6ab4e90c>.
----
FTL stack trace ("~" means nesting-related):
- Failed at: #include "/${parameters.templateDir}/... [in template "template/wam/checkbox.ftl" at line 23, column 1]
----
Java stack trace (for programmers):
----
freemarker.core._MiscTemplateException: [... Exception message was already printed; see it above ...]
at deployment.wam.war//freemarker.core.Include.accept(Include.java:164)
at deployment.wam.war//freemarker.core.Environment.visit(Environment.java:344)
at deployment.wam.war//freemarker.core.Environment.visit(Environment.java:350)
at deployment.wam.war//freemarker.core.Environment.process(Environment.java:323)
at deployment.wam.war//freemarker.template.Template.process(Template.java:383)
at deployment.wam.war//org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:152)
at deployment.wam.war//org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:595)
at deployment.wam.war//org.apache.struts2.components.UIBean.end(UIBean.java:554)
at deployment.wam.war//org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:36)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspx_meth_s_005fcheckbox_005f0(userRoles_jsp.java:302)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspx_meth_s_005fiterator_005f0(userRoles_jsp.java:254)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspService(userRoles_jsp.java:158)
CONFIDENTIALITY NOTICE: This communication with its contents may contain confidential and/or legally privileged information. It is solely for the use of the intended recipient(s). Unauthorized interception, review, use or disclosure is prohibited and may violate applicable laws including the Electronic Communications Privacy Act. If you are not the intended recipient, please contact the sender and destroy all copies of the communication.
Aw: Re: Sample JSP using Error and Exception Values without exception.message
Posted by Ute Kaiser <ut...@web.de.INVALID>.
Lukasz, thank you for updating the documentation.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Sample JSP using Error and Exception Values without exception.message
Posted by Lukasz Lenart <lu...@apache.org>.
pt., 30 maj 2025 o 19:45 Ute Kaiser <ut...@web.de.invalid> napisał(a):
> https://struts.apache.org/core-developers/exception-configuration
>
> I tried the "Sample JSP using Error and Exception Values"
> but <s:property value="%{exception.message}"/> was not displayed.
>
> Some error in my config, or outdated?
There is a bug in the doc, use <s:property value="exception"/>
https://github.com/apache/struts-examples/blob/main/exception-handling/src/main/webapp/error.jsp#L16-L17
BTW. %{...} force evaluation is not needed
Cheers
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Sample JSP using Error and Exception Values without exception.message
Posted by Ute Kaiser <ut...@web.de.INVALID>.
Hi,
https://struts.apache.org/core-developers/exception-configuration
I tried the "Sample JSP using Error and Exception Values"
but <s:property value="%{exception.message}"/> was not displayed.
Some error in my config, or outdated?
Best regards
Ute
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Re: Struts7 Allowlist Capability
Posted by Lukasz Lenart <lu...@apache.org>.
czw., 29 maj 2025 o 20:42 Ute Kaiser <ut...@web.de.invalid> napisał(a):
>
> Lukasz, thank you for your advice.
> I got rid of almost all by moving logic into the action and passing new flags to jsp instead.
>
> e.g.
> Migrating struts1
> <logic:present name="myList">
> <logic:notEmpty name="myList">
> by
> <s:if test="%{myList != null && !myList.isEmpty()}">
> raised
> WARN [org.apache.struts2.ognl.SecurityMemberAccess] (default task-2) Declaring class [class java.util.ArrayList] of member type [public boolean java.util.ArrayList.isEmpty()] is not allowlisted!
>
> Solution according to your advice:
> - Checking myList in the Action
> - passing a new flag hasData=true|false to the jsp
> - <s:if test="%{hasData}">
> worked.
Very good, thanks for sharing your thoughts and solution!
> One entry remaining in struts.allowlist.classes - the world won't end because of this :-)
That's good, it means your app is very secure :)
Cheers
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Aw: Re: Struts7 Allowlist Capability
Posted by Ute Kaiser <ut...@web.de.INVALID>.
Lukasz, thank you for your advice.
I got rid of almost all by moving logic into the action and passing new flags to jsp instead.
e.g.
Migrating struts1
<logic:present name="myList">
<logic:notEmpty name="myList">
by
<s:if test="%{myList != null && !myList.isEmpty()}">
raised
WARN [org.apache.struts2.ognl.SecurityMemberAccess] (default task-2) Declaring class [class java.util.ArrayList] of member type [public boolean java.util.ArrayList.isEmpty()] is not allowlisted!
Solution according to your advice:
- Checking myList in the Action
- passing a new flag hasData=true|false to the jsp
- <s:if test="%{hasData}">
worked.
One entry remaining in struts.allowlist.classes - the world won't end because of this :-)
Best regards
Ute
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts7 Allowlist Capability
Posted by Lukasz Lenart <lu...@apache.org>.
This happens if you use java.util.Locale directly in an expression -
SecurityMemberAccess is only involved if an OGNL expression is used.
Having said that, I wouldn't use any of java.* jakarta.* in OGNL
expressions as this brings a security risk. Moving such logic into
actions is the safest option.
czw., 29 maj 2025 o 13:17 Ute Kaiser <ut...@web.de.invalid> napisał(a):
>
> It is recommended enabling the allowlist capability with struts.allowlist.enable.
> I added my package names to the struts.allowlist.packageNames.
>
> But I get these warnings (leading to further errors)
> WARN [org.apache.struts2.ognl.SecurityMemberAccess] (default task-2) Declaring class [class java.util.Locale] of member type [public java.lang.String java.util.Locale.getLanguage()] is not allowlisted! Add to 'struts.allowlist.classes' or 'struts.allowlist.packageNames' configuration.
> Also for java.util.ArrayList, java.io etc.
>
> Is this really so restrictive?
> And if yes, is it ok to add "java,javax,jakarta"?
>
> I found this in org.apache.struts2.ognl.SecurityMemberAccess:
> private static final Set<Class<?>> ALLOWLIST_REQUIRED_CLASSES = Set.of(
> java.lang.Enum.class,
> java.lang.String.class,
> java.util.Date.class,
> java.util.HashMap.class,
> java.util.Map.class,
> java.util.Map.Entry.class
>
> Is this really so restrictive?
> And if yes, is it ok to add "java,javax,jakarta"? Or is that too much, so I could as well set struts.allowlist.enable=false?
> I am not sure how I identify the required classes (without testing the whole application)
> Unfortunately, I did the migration before I set struts.allowlist.enable=true.
>
> Best regards
> Ute
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Struts7 Allowlist Capability
Posted by Ute Kaiser <ut...@web.de.INVALID>.
It is recommended enabling the allowlist capability with struts.allowlist.enable.
I added my package names to the struts.allowlist.packageNames.
But I get these warnings (leading to further errors)
WARN [org.apache.struts2.ognl.SecurityMemberAccess] (default task-2) Declaring class [class java.util.Locale] of member type [public java.lang.String java.util.Locale.getLanguage()] is not allowlisted! Add to 'struts.allowlist.classes' or 'struts.allowlist.packageNames' configuration.
Also for java.util.ArrayList, java.io etc.
Is this really so restrictive?
And if yes, is it ok to add "java,javax,jakarta"?
I found this in org.apache.struts2.ognl.SecurityMemberAccess:
private static final Set<Class<?>> ALLOWLIST_REQUIRED_CLASSES = Set.of(
java.lang.Enum.class,
java.lang.String.class,
java.util.Date.class,
java.util.HashMap.class,
java.util.Map.class,
java.util.Map.Entry.class
Is this really so restrictive?
And if yes, is it ok to add "java,javax,jakarta"? Or is that too much, so I could as well set struts.allowlist.enable=false?
I am not sure how I identify the required classes (without testing the whole application)
Unfortunately, I did the migration before I set struts.allowlist.enable=true.
Best regards
Ute
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 7.0 issue with Ftl
Posted by Dave Newton <da...@gmail.com>.
On Wed, May 28, 2025 at 09:58 Priyanka Vaddadi
<Pr...@doj.ca.gov.invalid> wrote:
The following has evaluated to null or missing:
==> attributes.disabled [in template "template/wam/text.ftl" at line 51,
column 6]
If the app has its own theme/templates/etc they may need updating.
* https://struts.apache.org/getting-started/themes
* https://struts.apache.org/tag-developers/themes-and-templates
em: davelnewton@gmail.com
mo: 908-380-8699
gh: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>
RE: Struts 7.0 issue with Ftl
Posted by Priyanka Vaddadi <Pr...@doj.ca.gov.INVALID>.
Hi
When I change below code
<#if parameters.disabled?string?lower_case == "true">
disabled="disabled"<#rt/>
</#if> with
<#if attributes.disabled?string?lower_case == "true">
disabled="disabled"<#rt/>
</#if>
I am getting below error
FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!)
The following has evaluated to null or missing:
==> attributes.disabled [in template "template/wam/text.ftl" at line 51, column 6]
----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if attributes.disabled?string?lower_... [in template "template/wam/text.ftl" at line 51, column 1]
----
Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at deployment.wam.war//freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
at deployment.wam.war//freemarker.core.UnexpectedTypeException.newDescriptionBuilder(UnexpectedTypeException.java:85)
And how do I replace this code which is present in my ftl
<#if parameters.maxlength??>
maxlength="${parameters.maxlength}"<#rt/>
</#if>
I don't see maxLength property in attributes
And when I replace
<#if parameters.nameValue??>
value="<@s.property value="parameters.nameValue"/>"<#rt/>
</#if> with
<#if attributes.name??>
value="<@s.property value="%{attributes.name}"/>"<#rt/>
</#if>
I am getting parameter name displayed in text box but not parameter value
Please help me with this
Thanks and Regards
Priyanka
From: Priyanka Vaddadi
Sent: Tuesday, May 27, 2025 10:54 PM
To: user@struts.apache.org
Subject: Struts 7.0 issue with Ftl
Hi
I am getting below error while loading the page after migrating to struts 7
Pleaselet me know what could be the issue
Template inclusion failed (for parameter value "/Empty{name='templateDir'}/simple/checkbox.ftl"):
Template not found for name "Empty{name='templateDir'}/simple/checkbox.ftl".
The name was interpreted by this TemplateLoader: org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader@6ab4e90c<ma...@6ab4e90c>.
----
FTL stack trace ("~" means nesting-related):
- Failed at: #include "/${parameters.templateDir}/... [in template "template/wam/checkbox.ftl" at line 23, column 1]
----
Java stack trace (for programmers):
----
freemarker.core._MiscTemplateException: [... Exception message was already printed; see it above ...]
at deployment.wam.war//freemarker.core.Include.accept(Include.java:164)
at deployment.wam.war//freemarker.core.Environment.visit(Environment.java:344)
at deployment.wam.war//freemarker.core.Environment.visit(Environment.java:350)
at deployment.wam.war//freemarker.core.Environment.process(Environment.java:323)
at deployment.wam.war//freemarker.template.Template.process(Template.java:383)
at deployment.wam.war//org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:152)
at deployment.wam.war//org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:595)
at deployment.wam.war//org.apache.struts2.components.UIBean.end(UIBean.java:554)
at deployment.wam.war//org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:36)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspx_meth_s_005fcheckbox_005f0(userRoles_jsp.java:302)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspx_meth_s_005fiterator_005f0(userRoles_jsp.java:254)
at org.apache.jsp.WEB_002dINF.jspf.userRoles_jsp._jspService(userRoles_jsp.java:158)
CONFIDENTIALITY NOTICE: This communication with its contents may contain confidential and/or legally privileged information. It is solely for the use of the intended recipient(s). Unauthorized interception, review, use or disclosure is prohibited and may violate applicable laws including the Electronic Communications Privacy Act. If you are not the intended recipient, please contact the sender and destroy all copies of the communication.
Re: Struts 7.0 issue with Ftl
Posted by Lukasz Lenart <lu...@apache.org>.
śr., 28 maj 2025 o 12:25 Priyanka Vaddadi
<Pr...@doj.ca.gov.invalid> napisał(a):
>
> Hi
>
> I am getting below error while loading the page after migrating to struts 7
> Pleaselet me know what could be the issue
>
>
> Template inclusion failed (for parameter value "/Empty{name='templateDir'}/simple/checkbox.ftl"):
> Template not found for name "Empty{name='templateDir'}/simple/checkbox.ftl".
> The name was interpreted by this TemplateLoader: org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader@6ab4e90c.
>
> ----
> FTL stack trace ("~" means nesting-related):
> - Failed at: #include "/${parameters.templateDir}/... [in template "template/wam/checkbox.ftl" at line 23, column 1]
${parameters} has been replaced with ${attributes}, see the migration guide
https://cwiki.apache.org/confluence/display/WW/Struts+6.x.x+to+7.x.x+migration#Struts6.x.xto7.x.xmigration-Templatesparameters
Cheers
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org