8 Replies Latest reply on May 5, 2004 4:09 AM by aloubyansky

    Hierarchical Remote Interface

    ramiahbala

      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:

      <home-interface>VcrExtensionHome</home-interface>
      <remote-interface>Extension</remote-interface>
      <ejb-class>ExtensionEJB</ejb-class>




      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.

        • 1. Re: Hierarchical Remote Interface
          aloubyansky

          Could you please post the stacktrace and JBoss version?

          • 2. Re: Hierarchical Remote Interface
            ramiahbala

            JBOSS Version: 3.2.0
            Stack Trace:
            java.lang.ClassCastException
            $proxy0.findByPrimaryKey()

            Please note, when the call is made from a remote client, there is no error / exception in the server. The exception occurs in the client.
            When the call is made locally within the server, the same exception occurs within the server. The stack trace looks the same.

            • 3. Re: Hierarchical Remote Interface
              aloubyansky

              So is it thrown from the proxy class? Could you please post the whole stack?

              • 4. Re: Hierarchical Remote Interface
                ramiahbala

                Yes, indeed. I can see only one of the below 2 reasons.

                i) The proxy interface returned to the client implemented the return type of the findByPrimaryKey() method (Super interface)rather than the remote interface (Sub interface)configured in the deployment for the bean. This would result in the home proxy impl. trying to cast the remote proxy to the remote interface type which being a sub type, can cause ClassCastException to be thrown. But One would not expect an APP server to do it this way.

                2) As we know, findBy() methods can return the remote interface type or a Collection of them. If there is a bug in the CMP findBy() implementation code, it might check whether the return type is Remote Interface, if not return a Collection.

                Both of the above reasons may be absolutely my assumptions and not right. I am confident that it is to do with the findBy() implementation because create() works very well.

                • 5. Re: Hierarchical Remote Interface
                  darranl

                  ramiahbala,

                  Looks like you have missed the point of the previous post, loubyansky is asking for the full stack trace - the stack trace you have provided is useless.

                  • 6. Re: Hierarchical Remote Interface
                    aloubyansky

                     

                    "ramiahbala" wrote:

                    2) As we know, findBy() methods can return the remote interface type or a Collection of them. If there is a bug in the CMP findBy() implementation code, it might check whether the return type is Remote Interface, if not return a Collection.


                    This is the exact reason. It is fixed in JBoss3.2.4RC2. You can patch your JBoss version in org.jboss.ejb.EntityContainer in the server module.
                    Thanks.

                    • 7. Re: Hierarchical Remote Interface
                      ramiahbala

                      Loubyansky, Thanks mate. Looks like i got to do the patch.
                      Could you let me know how patches are to be done with JBOSS 3.2.0?
                      I have done it with 2.4.1 before by placing the patch jars in /patch directory in jboss installation directory.
                      How different it is in JBOSS 3.2.0?

                      Darranl, i did not post the full stack trace because it was pretty much useless. The remote call results in only one line of stack trace $proxy0.findByPrimaryKey(). Thanks.

                      • 8. Re: Hierarchical Remote Interface
                        aloubyansky

                        There is no patch directory now.
                        - fix the source code
                        - recompile the server module (you will find build.xml, .sh, .bat in the module directory)
                        - copy output/lib/jboss.jar to, e.g., server/default/lib overriding the old one.