This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes legal RMI-IIOP types? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "legal RMI-IIOP types?" Watch "legal RMI-IIOP types?" New topic
Author

legal RMI-IIOP types?

Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 172
Hi folks,

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?

Simon

Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Are the objects in the ArrayList serializable?


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Herbert Maosa
Ranch Hand

Joined: May 03, 2000
Posts: 289
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.
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 172
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.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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.
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 172
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: legal RMI-IIOP types?
 
Similar Threads
serialization
Return type of business home method
Examples of ILLEGAL RMI-IIOP Types
choosing between home business methods and finders
create and finder methods