• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to avoid invoking PortableRemoteObject.narrow()

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
We are migrating from weblogic6.1 to was5.
While executing this code
UserHome myHome = (UserHome) ic.lookup("UserHome");
Collection col = UserHome.findByName( name );
Iterator it = col.iterator();
while ( it.hasNext() ){
!!! User user =( User ) it.next(); !!!
. . .
}
we get ClassCastException: _EJBObject_Stub
It only takes place when find method returns Collection, methods which return bean allow explicit cast. They return _User_Stub instead of
_EJBObject_Stub. It's very strange behavior.
I know that RMI-IIOP requires using
(User) PortableRemoteObject.narrow(it.next(), User.class) to avoid this exception. It works fine in this case. But it's hard to change all such places.
Can anybody advise alternative way to fix the exception?
Assembly Tool compiles bean with -iiop rmic option by default. May it help if I compile bean without this option or it causes a crash of deployment?
Is it possible to use RMI instead of RMI-IIOP?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried using Access Beans? they avoid the direct lookup and narrow. (this is assuming you are trying to access an entity or session EJB.)
 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you make the entity beans local instead of remote, you don't need to perform the narrow()...
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...this assumes of course that you don't need them to be accessed remotely. I made this leap based upon your question about using RMI instead of RMI/IIOP...
reply
    Bookmark Topic Watch Topic
  • New Topic