Your ejbFindBySectorId returns IdSectorPKs.  The container transforms those
to instances of the remote inteface (IdSector??)
Try casting to the remote interface.

-----Original Message-----
From: Jean-Michel DELSAUX [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 29, 2001 8:37 AM
To: [EMAIL PROTECTED]
Subject: [jBoss-User] java.lang.ClassCastException: $Proxy1


Hi, I have the next function (see below)

It returns an Enumeration of IdSectorPK.  But we know that at the ckient 
part,
we have to cast.  the problem is that when i cast, i got an error:
  java.lang.ClassCastException: $Proxy1

Why can't i cast to IdSectorPK???????????????????

Please help.

JMi

=========================
client code
===========
  IdSectorHome home = (IdSectorHome) PortableRemoteObject.narrow (ref3, 
IdSectorHome.class);
  Enumaration enum = home.findBySectorId("XX");
  while(theEnum.hasMoreElements()) {
    Object obj = theEnum.nextElement();
    System.out.println(" ID: " + obj);
    //System.out.println("  CLASS: " + obj.getClass());
    IdSectorPK pro = (IdSectorPK) obj;//this line build an error
                                      //java.lang.ClassCastException:
$Proxy1 at 
client.main(client.java:143)
  }



==========================
Server code
===========
Enumeration findBySectorId(String sectorId) throws RemoteException, 
FinderException;//Home interface

public Enumeration ejbFindBySectorId(String sectorId) throws FinderException

{
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    Vector keys = new Vector();
    try {
      con = this.getConnection();
      ps = con.prepareStatement(
        "SELECT id_sect FROM vsect WHERE sector_id = ?");
      ps.setString(1, sectorId);
      //Execute the Query
      rs = ps.executeQuery();
      while(rs.next()) {
        IdSectorPK sectorPk = new IdSectorPK(rs.getInt("ID_SECT"));
        keys.addElement(sectorPk);
      }
    } catch(SQLException se) {
      //throw new EJBException(se);
    } finally {
      try {
        if(rs != null) rs.close();
        if(ps != null) ps.close();
        if(con != null) con.close();
      } catch(SQLException se) {
        se.printStackTrace();
      } finally {
        //Always return collection, even if empty
        return keys.elements();
      }
    }
  }
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to