ejb@glassfish.java.net

RE: RE: Re: Returning a List from a Stateless EJB throwsaStackOverflowError

From: Todd Patrick <Todd.Patrick_at_dtn.com>
Date: Fri, 2 Mar 2007 14:16:55 -0600

Ken Cavanaugh: Issue solved. Thank you very much for pointing this out. Changing to an ArrayList from a LinkedList was the solution. I appreciate you helping me with this issue and teaching me something new as well. --Todd ________________________________ From: Ken.Cavanaugh_at_Sun.COM [mailto:Ken.Cavanaugh_at_Sun.COM] Sent: Friday, March 02, 2007 1:31 PM To: Todd Patrick Cc: ejb Subject: RE: RE: Re: Returning a List from a Stateless EJB throwsaStackOverflowError On Fri, 2007-03-02 at 13:06 -0600, Todd Patrick wrote: Ken: It is a Linked List. I am running the following: Sun Java System Application Server Platform Edition 9.0_01 (build b14) Java(TM) SE Runtime Environment (build 1.6.0-b105) JSF 1.2_03 Below is the method that builds the Linked List. Thank you for your time to look at this. Is it an issue to be using a Linked List? Yes. The problem is that the fast reflective object copier needs to traverse the entire object graph in order to copy it, and this is necessarily recursive (obviously I could simulate the recursion, but it's easier just to recurse in the copier). I think changing from LinkedList to ArrayList will probably fix this problem, and is most likely more efficient as well. An ArrayList just allocates (and re-allocates) a backing array as needed, while the LinkedList is allocating lots of LinkedList.Entry nodes for the next and prev pointers. An ArrayList is usually a better choice. It is also helpful if you have some idea of the size of the results to pass the size in the ArrayList constructor. Ken. ----------------------------------------- NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.