Struts2 : FreeMarker template error: UBUNTU OS, but - struts2

When we run below code in windows its running fine. But in UBUNTU, its throwing below exception
Code:
<s:textfield name="realname" id="realname" placeholder="User Name" class="form-control" > </s:textfield>
FreeMarker template error:
The following has evaluated to null or missing:
==> ww [in template "template/simple/text.ftl" at line 10, column 11]
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. (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: #ww.property value="parameters.nameVa... [in template "template/simple/text.ftl" at line 10, column 9]
Java stack trace:
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
at freemarker.core.UnexpectedTypeException.newDescriptionBuilder(UnexpectedTypeException.java:85)

Related

How can I include code in a scaffolding view template in Grails 5?

I need to import one of my classes in one of my scaffolding views, this used to work in Grails 2 but now appears broken under 5.
I've tried both the GSP and JSP way of importing and both result with the same exception.
The error is as follows..
Message
Request processing failed; nested exception is groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: GStringTemplateScript3.groovy: 3: Unexpected input: '# page import' # line 3, column 13. """; # page import="tst.Customer" ; ^ 1 error
Caused by
Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: GStringTemplateScript3.groovy: 3: Unexpected input: '# page import' # line 3, column 13. """; # page import="tst.Customer" ; ^ 1 error
Thank you,

Cannot use index variable in thymeleaf template after 100th use on an array

When I try to use the same variable as an array's index 101th times (even over multiple renderings of my view), I have an exception on evaluating the expression. I have to restart my server to evaluate the expression again (until the 101th evaluation).
<th:block th:with="array=${new String[]{'item1'}}, index=0">
<th:block th:each="i : ${#numbers.sequence( 1, 101, 1)}">
[[${i}]]:[[${array[index]}]]
</th:block>
</th:block>
Result is :
1:item1 2:item1 [...] 100:item1 101:
Exception is :
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "array[index]" (template: "test.html" - line 10, col 13)
at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:290)
Caused by: java.lang.IllegalStateException: Failed to instantiate CompiledExpression
at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:111)
Caused by: java.lang.VerifyError: (class: spel/Ex3, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Expecting to find integer on stack
at java.lang.Class.getDeclaredConstructors0(Native Method)
Environment is :
thymeleaf version:'3.0.11.RELEASE'
thymeleaf-spring5 version:'3.0.11.RELEASE'
Tomcat 9.0.36
JDK 1.8.0_74
What's going on ?
The error snippet here mentions that Spring is attempting to compile the expression:
SpelCompiler.compile()
And, as you note, the problem is very specifically when the code attempts more than 100 array index accesses - even if the index variable never changes:
array[index]
It's interesting to note that I did not get this error when I hard-coded the index value - for example:
array[0]
I know of 2 ways around the problem:
Option 1
Configure SpEL to not use expression compilation. How you do this depends on your specific config set-up, but the setting is:
spring.expression.compiler.mode=off
I tried using mode immediate and also mode mixed - but neither worked. Only mode off.
Option 2
Avoid using an array with an index variable - for example there is no problem iterating over a list (or an array) like this, where the list contains more than 100 objects:
<th:block th:each="i,iterStat : ${myList}">
[[${iterStat.index}]]:[[${i}]]
</th:block>
Whether this option works for you probably depends on the wider context of what your code is doing. So this may not be an option.
Either way, I was surprised that the mixed compilation mode did not work. The documentation does note, however, that there are limitations to what the compiler can handle.
Just as an observation: I am assuming that you want to use the [[...]] syntax in your template, as opposed to something more like this:
<th:block th:each="i,iterStat : ${myList}">
<span th:text="${iterStat.index} + ':' + ${i}"></span>
</th:block>
(Doing things this way does not avoid the compilation problem, though.)

Facing issues when upgrading Struts from version 2.0.11.2 to 2.3.28.1

I have an application which is using Struts 2.0.11.2.The application is flagged as vulnerable due to the old version of struts.I am facing issues while upgrading the struts to version 2.3.28.1(this is the latest allowed version in our organization).
After a lot of research on google i understood that the Dojo classes are deprecated in the new struts version. However our project uses a lot of dojo tags.
I am aware of the alternative plugins such as Struts Jquery. But use of alternative plugins will involve a lot of code change and testing which is not feasible in the current time frame we have got.
Is there some way out to use the dojo tags with the struts to version 2.3.28.1?.
Can we somehow incorporate the struts2-dojo-plugin with the Struts version 2.3.28.1?.
i tried it myself but am getting stuck(details mentioned below)
What i tried:
1) I replaced the Struts core jar with struts2-core-2.3.28.1 jar.
2) Updated all the dependency jars as mentioned in the Maven repository.
3) Added struts2-dojo-plugin-2.3.20.1
4) Included in JSP-s
<%# taglib prefix="sx" uri="/struts-dojo-tags"%>
<head><sx:head /></head>
The issue i am facing:
When i hit the JSP below is the error i get. Any help is highly appreciated.Let me know if you need any more details or information from my side.
FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!)
The following has evaluated to null or missing:
==> parameters.pushId [in template "template/ajax/submit.ftl" at line 103, 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 be legally refer to something that's 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 parameters.pushId [in template "template/ajax/submit.ftl" at line 103, column 1]
----
Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:116)
at freemarker.core.UnexpectedTypeException.newDesciptionBuilder(UnexpectedTypeException.java:60)
at freemarker.core.UnexpectedTypeException.<init>(UnexpectedTypeException.java:40)
at freemarker.core.NonBooleanException.<init>(NonBooleanException.java:44)
at freemarker.core.Expression.modelToBoolean(Expression.java:136)
at freemarker.core.Expression.evalToBoolean(Expression.java:119)
at freemarker.core.Expression.evalToBoolean(Expression.java:110)
at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:46)
at freemarker.core.Environment.visit(Environment.java:312)
at freemarker.core.MixedContent.accept(MixedContent.java:62)
at freemarker.core.Environment.visit(Environment.java:312)
at freemarker.core.Environment.process(Environment.java:290)
at freemarker.template.Template.process(Template.java:312)
at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:158)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:584)
at org.apache.struts2.components.ClosingUIBean.start(ClosingUIBean.java:57)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54)
at jsp_servlet._demotool.__fileupload._jsp__tag2(__fileupload.java:332)
at jsp_servlet._demotool.__fileupload._jspService(__fileupload.java:236)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:502)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:432)
at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163)
at jsp_servlet._demotool.__ctmmessage._jspService(__ctmmessage.java:132)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:502)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:432)
at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163)
at jsp_servlet._demotool.__home._jspService(__home.java:255)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:90)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:91)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

How change yeoman generator-webapp settings to make uploadble files

I begin to use yeoman to make web pages. I finished almost. And I typed 'grunt' not 'grunt serve' to make up-loadable files.
terminal said errors below.But Cords work.
what should I fix.
app/scripts/main.js
2:3 error Strings must use singlequote quotes
2:3 error Expected indentation of 4 space characters but found 2 indent
5:7 error "slideqty" is defined but never used no-unused-vars
50:5 error "map" is defined but never used no-unused-vars
52:1 error Expected indentation of 2 space characters but found 0 indent
55:17 error "google" is not defined no-undef
58:13 error "google" is not defined no-undef
62:1 error "google" is not defined no-undef
62:1 error Expected indentation of 2 space characters but found 0 indent
✖ 22 problems (22 errors, 0 warnings)
Warning: Task "eslint:target" failed. Use --force to continue.
Aborted due to warnings.

jsf richFaces treeNode expanded - how to call a method with argument?

Facelet works fine in tomcat8, but in wildfly8 (jboss8) I get stack trace on first click of expand tree node icon.
<jsf.version>2.1.13</jsf.version>
<org.richfaces.version>4.3.7.Final</org.richfaces.version>
following facelet fragment:
<rich:tree id="tree" value="#{categoryBean.categoryNodes}" var="categName" prependId="true" selectionType="ajax" toggleType="ajax" >
<rich:treeNode prependId="true"
expanded="#{carelineBean.shouldExpandTree(categName)}"
toggleListener="#{carelineBean.expandNode(categName)}" >
<h:outputText value="#{categName}" />
</rich:treeNode>
</rich:tree>
in jboss at first click on expand icon I get stack trace:
[Server:server-one] Caused by: javax.el.PropertyNotWritableException: /editCall.xhtml #88,156 expanded="#{carelineBean.shouldExpandTree(categName)}": Illegal Syntax for Set Operation
[Server:server-one] at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:136)
[Server:server-one] at org.richfaces.component.AbstractTree.broadcast(AbstractTree.java:301)
[Server:server-one] ... 50 more
[Server:server-one] Caused by: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
the next click successfully expands tree branch without stack trace
The doc of expanded states:
Determines if this tree node is expanded. When EL expression used, it should use request-scoped variable with name defied in tree attribute 'var' which points to current node.
How can I decide if node should be expanded in method of backing bean, method must know the current node which should be expanded? Why is it working right in tomcat, but not in wildfly ?
According to
Makhiel: RF 4.3.x is not supported on WildFly.
Where can I find this information, RF is jboss product and is not supported in jboss8 ?!
Is RF supported in jboss 7.x ?
How can RF be best replaced ? I need sth like rf:tree and rf:treenode.
Is RF 3.x supported in jboss 7.x, wildfly 8 ?
I have rewritten ${carelineBean.shouldExpandTree(categName)} to ${categName.shouldExpandTree}, and this is working;

Resources