Help, Vector not being passed correctly!

Discussions

EJB programming & troubleshooting: Help, Vector not being passed correctly!

  1. Help, Vector not being passed correctly! (5 messages)

    I'm having a problem passing an object to a Stateless Session Bean that contains a Vector. I can verify that my object's Vector contains data at the client end, but in my EJB, the Vector is empty. All my contents are serializable, and to prove it to myself, I broke my problem into this simplified version:

    Client code:

    try {
        TestBean bean = getBean();
        List v = new LinkedList(); // <= This works
    // List v = new Vector(); // <= This does NOT work
        v.add("this is");
        v.add("really");
        v.add("weird");
        boolean works = bean.isWorking(v);
        System.out.println("works = " + works);
    } catch (Exception e) {
        e.printStackTrace();
    }


    Bean's method's code:

    public boolean isWorking(List v) {
        System.out.println("size=" + v.size());
        for (int i = 0; i < v.size(); i++) {
            System.out.println(v.get(i));
        }
        return v.size() > 0;
    }


    In the client, if I use a LinkedList, then all works fine. If I use a Vector, the bean returns false, and prints "size=0" in my app server's console. In another experiment while using the Vector as the parameter, ".size()" returns 0, but ".capacity()" throws a null pointer exception from within the Vector class.

    Any ideas what might be going on here? I'm stumped.

    I'm running SUN ONE 7.0.0_01 on Win2K.

    Threaded Messages (5)

  2. It's a JVM problem... but why?[ Go to top ]

    It seems it's a problem with JVM versions. I checked my app server's jvm and it's 1.4.1_01. I was running the client on 1.4.2_01. Downgrading my client to 1.4.1_01 fixes the problem with Vector. This isn't a good overall solution for my case though. But at least I know what trigger's the problem.

    Looks like a bug report to me... Has anyone had success with these combinations of jvm's? Or might this be a SUN ONE specific issue.
  3. Vector is a deprecated. You should use the new Collection classes such as ArrayList
  4. Really? Where did you find that Vector is deprecated?
  5. regarding vector[ Go to top ]

    there is no method in vector with name add().
    for adding element in a vector
    we use v.addElement("u r adding element")
    ok go through u r api
  6. regarding vector[ Go to top ]

    What do you mean there's no "add" in Vector? It's part of the List interface, that Vector satisfies. "add", most definately, is a method in Vector.

    I problem isn't that I'm having trouble adding data to a Vector. The fact that the data gets destroyed in the Vector (And *only* a Vector) is the puzzling part.