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

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;

Related

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)

Set the maxParameterCount attribute on the Connector JBoss EAP6

I have a main page with many elements included to another page but with different parameters using jsf 2.2 and it works with seam & jboss 5, but with jboss EAP6 (without seam) it gives me those errors :
java.lang.IllegalStateException: JBWEB002004: More than the maximum number of request parameters (GET plus POST) for a single request (512) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.
org.apache.tomcat.util.http.Parameters.addParameter(Parameters.java:184)
org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:360)
org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:213)
org.apache.catalina.connector.Request.parseParameters(Request.java:2858)
org.apache.catalina.connector.Request.getParameter(Request.java:1279)
org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:349)
com.sun.faces.context.RequestParameterMap.containsKey(RequestParameterMap.java:99)
java.util.Collections$UnmodifiableMap.containsKey(Collections.java:1337)
org.jboss.weld.jsf.WeldPhaseListener.getConversationId(WeldPhaseListener.java:171)
org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:99)
org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)
com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
Any idea to solve these?
I searched and I have found this :
<system-properties>
<property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>
</system-properties>
I found that I have to add that to standalone.xml but when I tried it doesn't start.

NullPointer Exception at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:314)

What can this exception mean exactly?
java.lang.NullPointerException: WriteText method cannot write null text
at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:314)
at org.icefaces.impl.context.DOMResponseWriter.writeText(DOMResponseWriter.java:340)
this is only happening when deployed using icefaces autoCompleteEntry tag having value attribute set to backing bean property selectedplcofBirth defined as emptystring "".(i.e. private String selectedplcofBirth="";)
<ace:autoCompleteEntry id="txtplaceofbirth"
rows="10" autocomplete="false"
minChars="2" width="150"
value="#{inputPersonal.selectedplcofBirth}"
filterMatchMode="none"
valueChangeListener="#{inputPersonal.valueChangeEventCity}">
<f:selectItems value="#{inputPersonal.cities}"/>
</ace:autoCompleteEntry></h:outputFormat>
You omitted the most important line of the stacktrace, the line thereafter:
at com.sun.faces.renderkit.html_basic.OutputMessageRenderer.encodeEnd(OutputMessageRenderer.java:163)
(see also this exact duplicate question of your colleague or clone account)
This exception occurs in older Mojarra versions when <h:outputFormat> is been used without value or null as value. E.g.
<h:outputFormat value="#{null}">...</h:outputFormat>
or
<h:outputFormat>...</h:outputFormat>
You should make sure that it is not null, or if the tag has no purpose at all, as confirmed by your comment on the question, just remove it altogether. Use a <h:panelGroup> instead. Or just learn CSS properly and fix your CSS selector.
What specific version of ICEfaces are you using? I was trying to line up the line numbers in the stack trace with a specific ICEfaces release to help troubleshoot. If you are using an older version, it might be worth trying to upgrade.

JSF 2 OpenJPA 2 Glassfish 3.1 WEB9031 Error

I got this error which according to Apache Support is an issue relating with Glassfish rather than OpenJPA:
java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.apache.openjpa.util.LongId], because it has not yet been started, or was already stopped
The stacktrace is:
Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.apache.openjpa.util.LongId], because it has not yet been started, or was already stopped
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1410)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
at com.ckd.model.BookModel.pcNewObjectIdInstance(BookModel.java)
at org.apache.openjpa.enhance.PCRegistry.newObjectId(PCRegistry.java:138)
at org.apache.openjpa.meta.MetaDataRepository.processRegisteredClass(MetaDataRepository.java:1693)
at org.apache.openjpa.meta.MetaDataRepository.processRegisteredClasses(MetaDataRepository.java:1643)
... 112 more
Has anyone come across this before and how to resolve it? I have been stuck on this issue for the last several days.
Another of my post related to this issue can be found here: JSF 2: h:link and getrowdata.
The above error relates to a problem with the OpenJPA enhancer. When you execute Sun's JDK the OpenJPA's dynamic enhancer starts by default. This action, in turn, stuffs up Glassfish's classloader class - hence, the WEB9031 error.
For those who experience this same issue, a simple workaround is to do the enhancement at build time - which I did in ANT with org.apache.openjpa.ant.PCEnhancerTask - and add this property to your persistence.xml to shut off the dynamic enhancer: <property name="openjpa.DynamicEnhancementAgent" value="false"/>.
Also, it wouldn't hurt to throw this in your persistence.xml as well <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" />.

Resources