1 Reply Latest reply on Dec 14, 2005 12:38 PM by Jose Freire

    Problem with a ArrayList (have I found a Bug?)

    Jose Freire Newbie

      Can't a ArrayList be passed as a parameter?

      If I pass a ArrayList as a parameter, the changes made to that ArrayList inside the container don't return to the client!

      Consider this simple interface:

      import java.util.ArrayList;
      import javax.ejb.Remote;

      @Remote
      public interface Echo {

      public ArrayList doEcho(ArrayList myList);

      }

      And the corresponding Session bean:

      import java.io.Serializable;
      import java.util.ArrayList;

      import javax.ejb.Stateful;

      @Stateful
      public class EchoBean
      implements Echo, Serializable
      {
      public ArrayList doEcho(ArrayList myList)
      {
      myList.add("ECHO");
      return myList;
      }
      }


      And the folowing test:

      ArrayList myList = new ArrayList();
      InitialContext ctx = new InitialContext();
      Echo myEcho = (Echo) ctx.lookup(Echo.class.getName());
      Echo myLocalEcho = new EchoBean();

      myLocalEcho.doEcho(myList); // After this point we have one item on myList
      myEcho.doEcho(myList); // After this point myList should have two items, but still only has one!

      myList = myEcho.doEcho(myList); // Ok, now we have two items on the List!

      Does this mean that we have a behavior for remote calls diferent from the local call, and we need to return the ArrayList like a function? Am I wrong or is this a bug?

      I'm using JBoss 4.0.3SP1 on Windows XP.

      Thanks,
      Jose