0

We are running Struts 2.5.14.1 and working on externalizing Tomcat session state. This requires Serializable sessions. However, our Action with the ExecuteAndWait interceptor fails. Since our original code was quite complex I wrote a simpler one below which demonstrates the exact same behavior.

The simple action is shown here:

package com.sentrylink.web.actions;

import java.util.concurrent.TimeUnit;

import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
@Results({
    @Result(name="wait", location="/"),
    @Result(name=ActionSupport.SUCCESS, location="/WEB-INF/content/messagePage.jsp"),
})
@InterceptorRefs({
    @InterceptorRef("webStack"),
    @InterceptorRef("execAndWait")
})
public class TestExecuteAndWait extends ActionSupport {

    public String execute() throws Exception {
        TimeUnit.SECONDS.sleep(10);
        return SUCCESS;
    }

}

Running this gives

WARNING: Cannot serialize session attribute __execWaittest-execute-and-wait for session 74CDB9F8D00BBC697030AFC6978E94F6 
java.io.NotSerializableException: com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector

It appears that Struts is pulling in an unwanted item for serialization. It may be related to the bug described here, although the fix put in for that bug appears to be present in 2.5.14.1 (not surprisingly, since that fix was in 2013).

I suspect this is a bug in the framework, but before I go ahead and file a report, and figure out a workaround for myself, I thought I would see if anyone had a solution or had ever gotten ExecuteAndWait to work with serialized sessions.

Erica Kane
  • 3,137
  • 26
  • 36
  • The Struts folks have confirmed this is a bug and asked that I open a JIRA issue. It can be found here: https://issues.apache.org/jira/projects/WW/issues/WW-4900?filter=allopenissues – Erica Kane Dec 05 '17 at 19:51
  • your action doesn't implement serializable, stateless objects don't need to be serialized. – Roman C Dec 25 '17 at 01:47
  • It does if you want that particular interceptor to work. However the Struts team has realized that forcing Actions to be serializable is not a good idea, and so that interceptor is officially not supported for serialized sessions now -- see the JIRA link above, – Erica Kane Dec 27 '17 at 11:12
  • Struts team didn't provide you with anything related to "serialized sessions". It's useless to check for every action or interceptor being serialized. – Roman C Dec 27 '17 at 14:33
  • Your use case is obviously different than mine...since I have already discussed this with the Struts folks I don't think this is a productive conversation. The JIRA ticket linked above is available for suggestions. – Erica Kane Dec 28 '17 at 17:31

0 Answers0