0 Replies Latest reply on Dec 19, 2005 3:14 AM by John Daratos

    A 'classcastexception' occurs when beans in a collection are

    John Daratos Newbie

      The following snippet code (executed on JBoss 4.0.2) results in a 'classcastexception' at the point marked '<--error here'.

      .........snippet start.........
      for (Iterator uldi=userLogonFields.iterator(); uldi.hasNext();) {
      UserLogonDetails uld = (UserLogonDetails) uldi.next(); <--error here
      UserLogonViewBean ulvb = new UserLogonViewBean();
      .........snippet end..........

      The code is part of a session bean that relies on an entity bean to return a collection of value objects (instances of UserLogonDetails), so that it can build a view bean for its caller (a servlet). The 'builder' is a Data Access Object (DAO) that is static and called via the standard DAO mechanism generated by the JBossIDE in Eclipse (using Bean Managed Persistence (BMP)). Everything works fine (all EJB calls via JNDI, etc.) until it executes the indicated point.

      I spent quite a bit of time debugging and trying different ways with to fix the problem to no avail. In my humble opinion, it appears that JBoss's BMP Persistence Manager wraps each object in $Proxy fashion and CacheKey, making access impenetrable (unless there is a way to extract the objects that I'm not aware of).

      Has anyone found a solution to this problem? Please advise.