0 Replies Latest reply on Aug 25, 2012 4:58 PM by 957960

    Serialization and Replication problems (ArrayStoreException), please help

      Hello to all this is Angelo from Italy, sorry for my english :p

      i'm facing a problem i cannot solve...it is about a week i'm trying to get a solution modifying code in every part.. but no luck. I think i don't know enough the java "serialization mechanism" maybe this is why i can't solve my problem and this is why i'm here writing to the experts. Maybe my question could be helpful for a lot of ppl. Well let's start. I say sorry in advance for the big post :p

      I'm working with JSF in a J2EE environment. I have 3 servers in a jboss cluster with sticky session enabled. In my web app i store some infos on a managed bean of session scope (SessionBean1, i code with netbeans ). I use a wrapper for all my grid (tables), that i show on the web page. The wrapper contains some ArrayDataModel properties to which components on the page are binded.

      The wrapper class (IdentitaOstMasterDM.java, attached) was this way (before the need of serialization)

      - See link to download files

      Some months later i needed to put the application in a distributable environment for session replication and so i needed to serialize everything... the wrapper class needed to be serializable (implemented Serializable interface) but ArrayDataModel properties were not serializable (ArrayDataModel does not implement serializable) so i ended up with creating a wrapper class for ArrayDataModel (SerializableObjectArray) that extends ArrayDataModel and implements Externalizable implementing writeExternal and readExternal methods:


      (note: Prima = Before, Dopo=After)
      package com.xxx.model;
      import java.io.Externalizable;
      import java.io.IOException;
      import java.io.ObjectInput;
      import java.io.ObjectOutput;
      import javax.faces.model.ArrayDataModel;
      public class SerializableObjectArray extends ArrayDataModel implements Externalizable
          public SerializableObjectArray(){
          public SerializableObjectArray(ArrayDataModel modello){
          public SerializableObjectArray(Object[] array){
          public void writeExternal(ObjectOutput oggetto) throws IOException {
              if(oggetto == null)
          public void readExternal(ObjectInput oggetto) throws IOException, ClassNotFoundException
              Object[] listaOggettiArray = null;
              if(oggetto == null)
              int rigaIndice = oggetto.readInt();
              System.out.println("Prima di readObject");
              Object elem = oggetto.readObject();
              System.out.println("Dopo di readObject");
              // leggo i dati serializzati
              if(elem != null){
                  listaOggettiArray = (Object[])elem;
                  if(listaOggettiArray != null){
                      System.out.println("ListaClass: " + listaOggettiArray.getClass());
                  System.out.println("ELEM is null");
              // setto il row
              if(rigaIndice > 0){
      and changed my session wrapper IdentitaOstMasterDM changing from ArrayDataModel to SerializableObjectArray just as follow.

      IdentitaOstMasterDM_new.java new

      -- See attached

      put <distributable /> on web.xml, added allowArraySyntax=true to JAVA_OPTS on all three JBOSS servers and started. i navigate the application till a detail page where i store my IdentitaOstMasterDM on session -> then i close the actual node -> wait for replication to happen -> try to navigate again but i receive this error:
      (of course on the new active node chosen of the cluster)

      -- See server.log attached

      attached also the web page (IdentitaOst_dett.jsp) where it is used the wrapper and the relative backing bean(IdentitaOst_dett.java)

      The Amministrativo Grid is null (no data inside) so the first arraydatamodel (first grid) populated (Attribuzione) give me this error..
      I've tried commenting out the attribuzione property and i got the same error on another one...

      Cause the ArrayStoreException is on the readObject() instruction (in SerializableObjectArray.java) i've started making changes in the readExternal with system.out, adding constructors and so forth but nothing....

      The weird thing i noticed is that if i use a class that extends SerializableObjectArray and implements Serializable (i.e. GridAttribuzione.java extends SerializableObjectArray implements java.io.Serializable ) and i use that class directly in the SessionBean1 as property, binding the visual component on it, all seems to be good... (i've tried with another page to bind a grid to a variable on SessionBean1 on a GridAttribuzione object) and in this page the replication seems working..
      that is the session is replicated and i have no ArrayStoreExceptions.

      So i think, now, that the problem stays in the wrapper class IdentitaOstMasterDM but i don't know where but overall why...and i would like to have your help if possible...

      Just to give you more infos i've tried to serialize locally the IdentitaOstMasterDM class with some data (with ObjectOutputStream and FileOutputStream on hard disk) . Writing and reading are done without problems...so i cannot replicate the problem locally and that drives me crazy cause every time i need to change the config on the three servers to try any code change ..

      If i've not been clear enough or you need more explanation please let me know: i will post the code so you can help me if you can and wish of course

      Thank you very much in advance my experts!
      All the best!

      Attached Files: [http://www.sendspace.com/file/fc9515]