在WebSphere Cluster Environment上未调用JSF 2 Ajax侦听器

时间:2016-04-09 05:44:45

标签: ajax jsf jsf-2 websphere-8

我们使用JSF 2.0.3版本和WebSpehere 8.5作为应用程序服务器。我们要求有两个selectmanylistbox,能够在两个盒子之间移动数据。请注意由于我们公司的限制,我不能使用Rich faces,Ice faces等。因此我尝试使用Ajax调用和监听器,如下面的代码来移动数据< / p>

    <h:commandButton id="lefttoright"  value="Left to Right"  >
 <f:ajax execute="listbox" render="sellistbox listbox" onevent="checkData"  listener="#{bean.leftToRight}" />
</h:commandButton> 

请注意我使用的是Viewscoped bean。现在,在我使用单节点单服务器WebSphere设置的本地RAD上,功能,即在盒子周围移动数据完全正常。

当我在WeSphere服务器上部署相同的代码时,该服务器有1个单元,2个节点,每个服务器有2个服务器,每个服务器都在集群中,&#34;左到右&#34;按钮只调用构造函数但不调用方法,即&#34; leftToRight&#34; 。直接在调用&#34; lefttoright&#34;日志中没有报告错误/异常。按钮。但是关于序列化会抛出持续的异常。不确定这是否会对Ajax调用产生任何直接影响。

 E SessionContextMBeanAdapter findAttCausingNotSerializableException Miscellaneous data: Attribute "com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap" is declared to be serializable but is found to generate exception "java.io.NotSerializableException" with message "com.sun.faces.context.FacesContextImpl".  Fix the application so that the attribute "com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap" is correctly serializable at runtime.

非常感谢任何反馈。如果我需要提供更多信息,请告诉我。

2 个答案:

答案 0 :(得分:1)

  带有消息“com.sun.faces.context.FacesContextImpl”的

“java.io.NotSerializableException”
  修复应用程序,以便属性“com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap”在运行时可正确序列化

所以,你有这样的事情:

@ViewScoped
public class Bean implements Serializable {

    private FacesContext context = FacesContext.getCurrentInstance();

    // ...
}

这绝对不对。您永远不应将FacesContext指定为某个类的实例变量,该类的实例长度超过FacesContext实例本身。

将其添加到方法局部范围中,而不是将其分配给任何实例变量。

@ViewScoped
public class Bean implements Serializable {

    public void someMethod() {
        FacesContext context = FacesContext.getCurrentInstance();
        // ...
    }

    // ...
}

这样表示JSF视图状态本身的LogicalViewMap将再次变为可序列化,并且依赖于JSF视图状态的任何内容将再次开始工作,例如依赖于视图范围变量的ajax请求。

只有在即将推出的JSF 2.3中,将它作为实例变量才是合法的,只要它是通过CDI注入的(CDI将照常注入一个可序列化的proxy,它可以进一步委托当前可用的实例)。

@ViewScoped
public class Bean implements Serializable {

    @Inject
    private FacesContext context;

    // ...
}

另见:

答案 1 :(得分:0)

基于进一步的分析,这个问题的根本原因是普通的日志jar被添加到lib文件夹中,并且在删除jar文件之后,所有的ajax调用开始处理任何问题。根据我的痛苦经历,我建议特别检查jar文件&#34;常见的日志记录&#34;如果你遇到任何奇怪的问题:)。请查看以下链接以获取参考http://articles.qos.ch/thinkAgain.html

相关问题