1 Reply Latest reply on Feb 21, 2002 12:23 PM by armint

    Container Factory error with business methods

    cdshearer

      Hello All

      I'm new to JBoss and just trying out some examples from the Mastering EJB 2.0 book. I'm using JBoss 2.4.4 and I'm trying out a BMP example.

      The book example shows a remote home interface with a business method on it (getTotalBankValue). However, when I deploy this EJB to JBoss, I get the following error:

      [ERROR,ContainerFactory]
      Bean : Account
      Method : public abstract double getTotalBankValue() throws AccountException, RemoteException
      Section: 9.2.8
      Warning: Each method defined in the entity bean's home interface must be either create or finder method.

      This puzzles me, for two reasons:

      1. I'm able to successfully call the method, so even though JBoss tells me this is an error, it doesn't affect the operation of the method.

      2. It seems odd that this sort of method goes on the home interface but gets implemented on the Bean. Why should the bean implement a method that doesn't actually apply to the bean data? It would seem that a better place to put this code would be on a Session Bean.

      Comments?

      regards,
      Craig (in New Zealand!)

        • 1. Re: Container Factory error with business methods
          armint

          2. It seems odd that this sort of method goes on the home interface but gets implemented on the Bean. Why should the bean implement a method that doesn't actually apply to the bean data? It would seem that a better place to put this code would be on a Session Bean.

          It can seem odd if you only think of entity beans as discrete instances with identity (i.e primary keys.) However, entity beans are also components encapsulating all the data associated with its particular instances, sort of a box with lot's of pieces inside. Generally in OO methodology, it is a good idea to have an object operate on its own data. Having another object, do so breaks encapsulation. This is the motivation of creating a home method, to have the component work on its own data. It's a bit strange at first that the home method is implemented in the bean implementation class because most of the class is designed to hold persistent fields and a primary key. Still, the method must be implemented somewhere and it cannot be in the home interface.