I have an entity bean finder method which returns a collection. My entity bean is implemented with local interfaces. I want to pass the results of the finder to my remote client and because Collection is not serializable, I loaded the collection into an ArrayList and tried to pass this (I do this via a remote session bean). I get a CORBA_BAD_PARAM: message and something in the stack trace suggesting NotSerializableForCorba. See below. I thought Collection was a legal RMI-IIOP type but the API docs suggested it was not serializable. ArrayList definitely is. Am I missing something here?
This has managed to get me lost a little bit. I have an entity bean that successfully passes a Collection object to a remote client, a servlet. However, the runtime type inside the collection is an ArrayList but I pass it out as a Collection, I wonder if that is what is making the difference.
The objects inside the collection are local component interface types from my entity bean. This is usually what multiple-row finders return. The collection would not go across the network and I assumed this was because collection is not serializable. ArrayList is, but it won't go either.
Wahtever is put into the ArrayList must be serializable, so some conversion from the interface types looks necessary. If you convert to a wrapper such as Integer you are fine, if you need to use a non-built-in data type then it must be declared serializable.
If I were using the findByPrimaryKey(key) method on a local entity bean I would get back the local component interface type, which is also an EJBLocalObject for the particular instance of my bean defined by the key. I am using a multiple finder and get back a collection of EJBLocalObjects. I was trying to pass this collection to a remote session bean and then pass the collection across the network to my client, who wants to call methods on the entity bean. Clearly this doesn't make sense. I can't use EJBLocalObjects as stubs! I now see my mistake, which is a conceptual one and may be of interest to the forum. I will have to encapsulate the data for each of the EJBLocalObjects retrieved from the entity bean and pass this data to the client and as you say Roger, this should probably be a serializable data holder. Then I should be OK. The idea underlying this exercise is that entity beans are fine grained components and should be deployed locally for performance purposes. Remote clients can then access entity beans via course grained (ideally stateless) session beans which move large chunks of data over the network. This approach (the SessionFacade design pattern) should yield a considerable performance advantage.