wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Help, Vector not being passed correctly! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Help, Vector not being passed correctly!" Watch "Help, Vector not being passed correctly!" New topic
Author

Help, Vector not being passed correctly!

Jeremy Jenkins
Greenhorn

Joined: Oct 24, 2003
Posts: 4
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:


Bean's method's code:

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.
Jeremy Jenkins
Greenhorn

Joined: Oct 24, 2003
Posts: 4
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.
Howard Kushner
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 361
Hello Jeremy,
I must confess that I am confused by your example. Why would one have a stateless session maintain some conversational state (i.e. maintain a reference to a vector)?
An EJB is a remote object. Your client (unless it is local to the bean) does not maintain a reference to the bean instance. Rather it is using a proxy that communicates indirectly with the bean via the container.
Since you say it is a stateless session bean, the container can use any available instance which it may have pooled. In other words, you are not guaranteed to be talking to the same bean from one method invocation to the next.
Hope this helps. Please let me know if there is anything more I can do to help clarify.
Regards,


Howard Kushner<br />IBM Certified Enterprise Developer - WebSphere Studio Application Developer V5.0<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - Web Services with WebSphere Studio V5.1<br /><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1931182108/" target="_blank" rel="nofollow">Developing J2EE Applications with WebSphere Studio</a> my Certification Study Guide for IBM Test 287
Jeremy Jenkins
Greenhorn

Joined: Oct 24, 2003
Posts: 4
Hi Howard,
Thanks for your reply. I have a bean that does some calculations. I give it a Vector, and it uses the objects contained within it to do some calculations. It then returns the "answer".
I populate the data Vector on the Client end, pass the vector to my remote stateless session bean (It doesn't need to keep track of state, only do "simple" calculations based on the arguments provided). The bean does the calculations and passes the answer back to my Client. I can verify that my data is within my collection on the Client end before the EJB call. Once in the EJB, I get puzzling behavior:
Using a Vector to pass data does *NOT* work.
Using an ArrayList to pass data *DOES* work.
Using a LinkedList to pass data *DOES* work.
Vector reports a size() of 0, and throws a null pointer exception upon calling capacity() (Coming from within the Vector... not that the Vector itself is null). The two other Collections work perfectly well.
This only happens when my client and app server are using differing JVM versions. When they match, Vector works. This seems like a rather significant bug to me.
Howard Kushner
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 361
Ok. Now I get it. So let me ask this... do you really need such a fancy collection? Are there truly arbitrary objects? If not then you could simplify your life perhaps with a simple array of some type, for example:

Jeremy Jenkins
Greenhorn

Joined: Oct 24, 2003
Posts: 4
Yeah, the collection can have 0 or more objects contained within it.
The situation is complicated by the fact that what is passed to the EJB is really an object that contains the collection I've described. I simplified my example test case to isolate the fact that the problem was being caused by the remote passing of a Vector argument. Anyway, the amount of bookeeping I would have to add to be able to use a plain array, would be reinventing a collection. As it is, I'm converting everything to an ArrayList (Which is a better solution anyway) to get around this problem.
I'm suprised noone else has seen this, however.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help, Vector not being passed correctly!
 
Similar Threads
How to write generic method for this method?
Array problem
Vector.size()
Copying from Vector to Array: any inbuilt java method available like List.addAll(Vector)
Problem with Array Value - Comparing Arrays.