0 Replies Latest reply on Apr 28, 2004 10:54 AM by ramiahbala

    ClassCastException in FindByPrimaryKey

    ramiahbala Newbie

      Hello Gurus,

      I have a home interface for a CMP 1.1 entity bean that has a create() method and a findByPrimaryKey() method. The return types of these methods are a super type of the remote interface, i.e the bean's remote interface extends the return type of these methods. The super interface itself is a valid remote interface as it extends EJBObject interface.

      The create() works alright. But, the findByPrimaryKey() throws a ClassCastException from the proxy.

      Code Sample:

      Home Interface:

      public interface VcrExtensionHome extends EJBHome {

      public abstract VcrExtension create(VcrExtensionDetails toCreate) throws CreateException, RemoteException;

      public abstract VcrExtension findByPrimaryKey(Integer vcrId) throws FinderException, RemoteException;


      Super Interface:

      public interface VcrExtension extends EJBObject {

      public Integer getValue() throws RemoteException;


      Bean's Remote Interface:

      public interface Extension extends VcrExtension {

      Deployment Description in short:


      Is it mandatory that the return type of the home interface should be the exact remote interface type and can't be a super type? If so, then I do not know why the create() works.

      In plain java terms, this should work fine. I am not sure whether the home proxy implementation in JBOSS takes different code paths for create() and findBy() methods and one of them has a bug.

      Any insight would be highly appreciated.

      Cheers in advance.