Search code examples
wildflywildfly-10infinispan

Wildfly 10 in cluster tries to serialize JSP with org.infinispan.commons.marshall.NotSerializableException


I'm trying to use my application with following code in JPS

<c:forEach var="area" items="#{MissingSearchBean.workingAreas}">
     <h:commandButton value="#{area.workingAreaName}(#{area.count})"
                         action="#{MissingSearchBean.selectWorkingArea(area.workingAreaName)}"
                         styleClass="commandButton" />
</c:forEach>

inside wilfly 10. Everything works fine, but when I open view, containing code above I see following error in logs:

Caused by: org.infinispan.commons.marshall.NotSerializableException: javax.servlet.jsp.jstl.core.IteratedExpression
Caused by: an exception which occurred:
    in field iteratedExpression
    in field delegate
    in field savedState
    in field m
    in object java.util.HashMap@85e645ff
    in object org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue@85e645ff

I think that wildfly tries to persist view into infinispan to be able to recover view in case if I'll reload page or hit this page on another node.

I've tried to change scope of bean to request and even to none, but wildfly still tries to serialize view. I'm absolutely sure that the problem is in c:forEach because when I comment it (ot its' content) out — I don't get any exceptions.

Also obviously IteratedExpression contains Iterator inside, which is not Serializable true.

I'm looking for any solution/workaround for this be able to work in cluster without throwing exceptions.


Solution

  • The problem is c:forEach creates IteratedValueExpression, which is not Serializable because contains the Iterator inside. Simple workaround for this is to change return type of MissingSearchBean.workingAreas to array.

    In case when value is represented by array, LoopTagSupport creates IndexedValueExpression instead of IteratedValueExpression and this is explicitly Serializable.