Tony Abbott wrote:
>
> findBy methods on the home interface should return either the remote interface
> or a Collection of remote interfaces. So just make findByParent return a
> collection of categories. So your code would look something like...
>
> InitialContext context = new InitialContext();
> Object obj = context.lookup("java:comp/env/ejb/Category");
> CategoryHome ch = (CategoryHome)PortableRemoteObject.narrow(obj, CategoryHome.class);
>
> Collection col = ch.findByParent("Furniture");
> Iterator i = col.iterator();
> while (i.hasNext())
> {
>    Category cat = (Category)i.next();
>    ... do stuff ...
> }
>
> -t

Tony,

In the above code, you neglected to use PRO.narrow for the narrowing of
the contents of the Iterator.  It should be:

        Collection col = ch.findByParent("Furniture");
        Iterator i = col.iterator();
        while (i.hasNext()) {
          Category cat = (Category) PortableRemoteObject.narrow
            (i.next(), Category.class);

        }

This is one of those insidious cases that I mentioned in a previous
thread, whereby your version of the code would work in some AppServers,
and not in others, even though (given your use of PRO.narrow for the
JNDI lookup) you probably thought you were writing portable code.

-jkw

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to