1 Reply Latest reply on Feb 24, 2002 7:00 PM by Armin

    JBoss 3.0 CMP 2.0 ejbCreate; fix for null values

    William Robinson Newbie

      Recently, I've been using CMP 2.0 in JBoss 3.0.

      In updating the CMP EJBs, I've received an error about a null primary key. (I also noticed, in the server log, that the other EJB values were null.) I've read a number of posts that have had similar problems, while other have said CMP 2.0 works great.

      I found that CMP 2.0 in JBoss requires that one use the (abstract) "set" methods in ejbCreate. If not, then the values will not be set. Thus, there are null keys, etc.

      Here's a bit from my (updated) JBoss CD tutorial.

      public Integer ejbCreate (Integer id) throws CreateException
      {
      // CANNOT SET VARS USING SIMPLE VARIABLE REFERENCE
      // this.id = id;
      // IN JBOSS, MUST USE THE GET/SET METHODS....
      setId(id);
      return null;
      }


      In any case, the above worked for me, whereas the more common "this.id = id;" did not.

      Bug or feature? You be the judge! :-)

      Hope that helps someone.