3 Replies Latest reply on Aug 9, 2002 4:50 AM by lqd

    Entity Proxy NullPointerException

    legerdemain


      Below is a partial stack trace when a CMP entity bean is created:

      java.lang.NullPointerException
      at com.visualfiles.workflow.ActivityAutoCreateBean$Proxy.setOrgId()
      at com.visualfiles.workflow.ActivityAutoCreateBean. ejbCreate(ActivityAutoCreateBean.java:41)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      ...

      NullPointerException occurs within the proxy whenever a field in the compound primary key is set within the ejbCreate method. Other fields outside the primary key do not throw this exception.

      Other beans using the same compound primary key have been created successfully within the same application. No relevant differences between the working beans and the ActivityAutoCreateBean can be discerned in either code or deployment description. Needless to say that no errors were reported whilst deploying this bean.

      If these exceptions are caught and simply ignored within ejbCreate (avoiding rollback) then a record is created perfectly within the table associated with the entity. Although it would be unwise to ignore this exception especially since its cause is unknown.

      It is very possible that I have not correctly set up something either within the code or the deployment descriptor since I am not familiar with EJB2.0. However, all the beans except this one work and the errant bean passes the deployment validation.

      I'm not happy posting this simply because of the paucity of the information supplied. But I have attempted to understand the source regarding the generation of entity proxy classes and have come to the conclusion that this will take a very significant amount of time.

      Michael.

        • 1. Re: Entity Proxy NullPointerException
          legerdemain


          Discovered the cause of this problem...

          public abstract int getOrgId();
          public abstract int setOrgId(int orgId);
          public abstract int getSiteId();
          public abstract int setSiteId(int siteId);
          public abstract int getId();
          public abstract int setId(int id);

          ... a return type of int in the setters. This causes the entity proxy to throw a NullPointerException.

          Now this was a really dumb thing to do but given that finding the problem was so difficult it might be good to have the validation check the return type of the setter methods.

          Sheepishly,

          Michael.

          • 2. Re: Entity Proxy NullPointerException
            dsundstrom

            Can you post a bug report in the JBossServer category? The guy who writes the verifier will see it then.

            • 3. Re: Entity Proxy NullPointerException
              lqd

              this is fixed in CVS (the verifier part). the more I think about it, we should make the verifier a mandatory step in the deployment process and simply disallow deployments which do not pass the verifier ...

              i will have a look at the NPE being thrown (this should not happen in the container), could take some time though as i'm not really familiar with the code.