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.