Does clustering Weld beans work in AS7.1?
macros77 Feb 22, 2012 8:09 AMI have two AS7.1 server and started them up using the standalone-ha.xml configuration with a mod_cluster apache http server in front of them.
I've got the following in a JSF page:
{code:xml}
<h:form id="test">
<div style="color: blue">
<h:messages id="messages" globalOnly="false"/>
<h:outputText id="currentId" value="The current Id is: #{basicTest.id}" /><br />
</div>
<div>
Set Id:
<h:inputText id="inputId" value="#{basicTest.id}" required="true" size="3" />
<h:commandButton id="setIdButton" value="Set Id" action="#{basicTest.load()}" />
</div>
</h:form>
{code}
My bean looks as follows:
{code}
@Named
@Stateful
@SessionScoped
public class BasicTest implements Serializable {
private Integer currentId;
public Integer getId() {
return this.currentId;
}
public void setId(Integer id) {
this.currentId = id;
}
{code}
When this is deployed I can go to the JSF page, set the value of id, click the button and the output text will show whatever value I set. If I were to refresh the page the number remains as would be expected. However, if I were to switch off the server that is currently serving the request and then try to refresh the page I get the following exception on the remaining node:
10:29:00,978 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host]] (http--127.0.0.1-8080-1) Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.servlet.WeldListener: java.lang.IllegalStateException: Error restoring serialized contextual with id org.jboss.weld.bean-basictest.war/F:/Development/servers/clustering/jboss-as-7.1.0.Final-server2/standalone/deployments/basictest.war/WEB-INF/classes-SessionBean-BasicTest
at org.jboss.weld.context.SerializableContextualImpl.loadContextual(SerializableContextualImpl.java:91) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.context.SerializableContextualImpl.get(SerializableContextualImpl.java:79) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.context.SerializableContextualImpl.delegate(SerializableContextualImpl.java:37) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.context.ForwardingContextual.toString(ForwardingContextual.java:46) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at java.lang.String.valueOf(String.java:2826) [rt.jar:1.6.0_27]
at java.lang.StringBuilder.append(StringBuilder.java:115) [rt.jar:1.6.0_27]
at org.jboss.weld.context.SerializableContextualInstanceImpl.toString(SerializableContextualInstanceImpl.java:60) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at java.lang.String.valueOf(String.java:2826) [rt.jar:1.6.0_27]
at java.lang.StringBuilder.append(StringBuilder.java:115) [rt.jar:1.6.0_27]
at org.jboss.weld.context.beanstore.AttributeBeanStore.attach(AttributeBeanStore.java:109) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.context.AbstractBoundContext.activate(AbstractBoundContext.java:66) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.jboss.weld.servlet.WeldListener.requestInitialized(WeldListener.java:141) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_27]
Also, were I to change my bean to use
{code}
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
{code}
rather then the weld alternatives everything works as expected.