13 Replies Latest reply on Apr 29, 2002 7:54 PM by giles

    CMP: JDBCCreateEntityCommand.execute

    kryptontri

      Stack Trace:
      [AddressEJB] setEntityContext
      [AddressEJB] ejbCreate : 5 : 1 : happyhacker@hl.com
      [AddressEJB] TRANSACTION ROLLBACK EXCEPTION:null
      Embedded Exception
      null; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      null
      [AddressEJB] java.lang.NullPointerException
      [AddressEJB] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:
      117)
      [AddressEJB] at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.createEntity(JAWSPersistenceManager.java:12
      8)
      [AddressEJB] at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:231)
      [AddressEJB] at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:616)
      [AddressEJB] at java.lang.reflect.Method.invoke(Native Method)
      [AddressEJB] at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:843)
      [AddressEJB] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterc
      eptor.java:231)
      [AddressEJB] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:154
      )
      [AddressEJB] at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:108)
      [AddressEJB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
      [AddressEJB] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:307)
      [AddressEJB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
      [AddressEJB] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:103)
      [AddressEJB] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
      [AddressEJB] at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:420)
      [AddressEJB] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:3
      70)
      [AddressEJB] at java.lang.reflect.Method.invoke(Native Method)
      [AddressEJB] at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
      [AddressEJB] at sun.rmi.transport.Transport$1.run(Unknown Source)
      [AddressEJB] at java.security.AccessController.doPrivileged(Native Method)
      [AddressEJB] at sun.rmi.transport.Transport.serviceCall(Unknown Source)
      [AddressEJB] at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
      [AddressEJB] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
      [AddressEJB] at java.lang.Thread.run(Unknown Source)

      Jaws.xml
      ----------
      <enterprise-beans>

      .... another entity bean that works..its the same almost apart from the finder and table + column names



      <ejb-name>AddressEJB</ejb-name>
      <table-name>ADDRESS</table-name>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>false</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <select-for-update>false</select-for-update>
      <pk-constraint>true</pk-constraint>

      <cmp-field>
      <field-name>addressId</field-name>
      <column-name>ADDRESSID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>addressTypeId</field-name>
      <column-name>ADDRESSTYPEID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>addressLine1</field-name>
      <column-name>ADDRESSLINE1</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>addressLine2</field-name>
      <column-name>ADDRESSLINE2</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>addressLine3</field-name>
      <column-name>ADDRESSLINE3</column-name>>
      </cmp-field>
      <cmp-field>
      <field-name>addressLine4</field-name>
      <column-name>ADDRESSLINE4</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>CITY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>countryId</field-name>
      <column-name>COUNTRYID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>email</field-name>
      <column-name>EMAIL</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>homePhone</field-name>
      <column-name>HOMEPHONE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>workPhone</field-name>
      <column-name>WORKPHONE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>mobile</field-name>
      <column-name>MOBILE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>icq</field-name>
      <column-name>ICQ</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>yahooMessenger</field-name>
      <column-name>YAHOOMESSENGER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>msnMessenger</field-name>
      <column-name>MSNMESSENGER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>aolMessenger</field-name>
      <column-name>AOLMESSENGER</column-name>
      </cmp-field>


      findByEmail
      EMAIL = {0}

      <read-ahead>true</read-ahead>





      </enterprise-beans>



      EJB Create
      -----------
      /**
      * EJB implementation ejbCreate creates a new record
      *
      * @return Integer - The new PK for this data record
      * @throws CreateException
      */
      public Integer ejbCreate ( Integer inAddressId,
      Integer inAddressTypeId,
      String inEmail )
      throws DuplicateKeyException, CreateException {

      if ( log.isDebugEnabled() ) {
      log.debug("ejbCreate : " + inAddressId + " : " + inAddressTypeId + " : " + inEmail);
      }

      addressId = inAddressId;
      addressTypeId = inAddressTypeId;
      email = inEmail;

      return null;
      }


      -----------------------------------------------------
      the stack trace refers to

      [AddressEJB] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:
      117)

      Which is ..

      id = from.get(ctx.getInstance());

      Any ideas why the container is returning the context as null ?

      Many thanks { jboss version 2.4.1 }

        • 1. Re: CMP: JDBCCreateEntityCommand.execute
          kryptontri

          sorry i meant:
          why is the id from the context null ? or am i on the wrong track/trace ? dammit i know kung fu ! lol

          • 2. Re: CMP: JDBCCreateEntityCommand.execute
            kryptontri

            any ideas anyone ?????? have i missed something basic ?

            • 3. Re: CMP: JDBCCreateEntityCommand.execute
              kryptontri

              come on someone ... any ideas ... i am stuck :(

              i have two ejbs almost the same yet the AddressEJB fails to work when creation takes place, yet the finder - findByEmail seems to work fine as SQL is called ?
              help ...

              • 4. Re: CMP: JDBCCreateEntityCommand.execute
                alu1344

                post the code in your ejbCreate and ejbPostCreate methods.

                • 5. Re: CMP: JDBCCreateEntityCommand.execute
                  kryptontri

                  /**
                  * EJB implementation ejbCreate creates a new record
                  *
                  * @return Integer - The new PK for this data record
                  * @throws CreateException
                  */
                  public Integer ejbCreate ( Integer inAddressId,
                  Integer inAddressTypeId,
                  String inEmail )
                  throws DuplicateKeyException, CreateException {

                  if ( log.isDebugEnabled() ) {
                  log.debug("ejbCreate : " + inAddressId + " : " + inAddressTypeId + " : " + inEmail);
                  }

                  addressId = inAddressId;
                  addressTypeId = inAddressTypeId;
                  email = inEmail;

                  return null;
                  }


                  /**
                  * EJB implementation ejbPostCreate is called by the container after ejbCreate(). Note the signature
                  * must match ejbCreate()
                  *
                  * @param AccountBean
                  * @throws CreateException
                  */
                  public void ejbPostCreate( Integer inAddressId,
                  Integer inAddressTypeId,
                  String inEmail )
                  throws DuplicateKeyException,CreateException {

                  if ( log.isDebugEnabled() ) {
                  log.debug("ejbPostCreate");
                  }
                  }



                  I am positive i have not missed something basic ? Both have the same signature

                  • 6. Re: CMP: JDBCCreateEntityCommand.execute
                    kryptontri

                    any ideas ? i am still stuck :(

                    • 7. Re: CMP: JDBCCreateEntityCommand.execute
                      vincent

                      I guess the declaration of your PK is wrong in ejb-jar.xml.
                      Can you post this one ?

                      • 8. Re: CMP: JDBCCreateEntityCommand.execute
                        kryptontri

                        my pk type is Integer, smae as the other ejb ??

                        <?xml version="1.0"?>

                        <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

                        <ejb-jar>
                        <enterprise-beans>


                        This is the AccountEJB

                        <ejb-name>AccountEJB</ejb-name>
                        com.ktll.dating.ejb.AccountHome
                        com.ktll.dating.ejb.Account
                        <ejb-class>com.ktll.dating.ejb.AccountEJB</ejb-class>
                        <persistence-type>Container</persistence-type>
                        <prim-key-class>java.lang.Integer</prim-key-class>
                        False

                        <cmp-field><field-name>accountId</field-name></cmp-field>
                        <cmp-field><field-name>accountName</field-name></cmp-field>
                        <cmp-field><field-name>cardType</field-name></cmp-field>
                        <cmp-field><field-name>cardNumber</field-name></cmp-field>
                        <cmp-field><field-name>sortCode</field-name></cmp-field>
                        <cmp-field><field-name>expiryDate</field-name></cmp-field>
                        <cmp-field><field-name>creationDate</field-name></cmp-field>
                        <cmp-field><field-name>lastLogin</field-name></cmp-field>
                        <cmp-field><field-name>accountDisabled</field-name></cmp-field>
                        <cmp-field><field-name>userName</field-name></cmp-field>
                        <cmp-field><field-name>password</field-name></cmp-field>

                        <primkey-field>accountId</primkey-field>


                        <security-role-ref>
                        Caller must be in this role
                        <role-name>everyone</role-name>
                        </security-role-ref>




                        This is the AddressEJB

                        <ejb-name>AddressEJB</ejb-name>
                        com.ktll.dating.ejb.AddressHome
                        com.ktll.dating.ejb.Address
                        <ejb-class>com.ktll.dating.ejb.AddressEJB</ejb-class>
                        <persistence-type>Container</persistence-type>
                        <prim-key-class>java.lang.Integer</prim-key-class>
                        False

                        <cmp-field><field-name>addressId</field-name></cmp-field>
                        <cmp-field><field-name>addressTypeId</field-name></cmp-field>
                        <cmp-field><field-name>addressLine1</field-name></cmp-field>
                        <cmp-field><field-name>addressLine2</field-name></cmp-field>
                        <cmp-field><field-name>addressLine3</field-name></cmp-field>
                        <cmp-field><field-name>addressLine4</field-name></cmp-field>
                        <cmp-field><field-name>city</field-name></cmp-field>
                        <cmp-field><field-name>countryId</field-name></cmp-field>
                        <cmp-field><field-name>email</field-name></cmp-field>
                        <cmp-field><field-name>homePhone</field-name></cmp-field>
                        <cmp-field><field-name>workPhone</field-name></cmp-field>
                        <cmp-field><field-name>mobile</field-name></cmp-field>
                        <cmp-field><field-name>icq</field-name></cmp-field>
                        <cmp-field><field-name>yahooMessenger</field-name></cmp-field>
                        <cmp-field><field-name>msnMessenger</field-name></cmp-field>
                        <cmp-field><field-name>aolMessenger</field-name></cmp-field>


                        <primkey-field>addressId</primkey-field>


                        <security-role-ref>
                        Caller must be in this role
                        <role-name>everyone</role-name>
                        </security-role-ref>






                        </enterprise-beans>

                        <assembly-descriptor>
                        <security-role>

                        This role represents everyone who is allowed full access
                        to the Account bean.

                        <role-name>everyone</role-name>
                        </security-role>

                        <method-permission>
                        <role-name>everyone</role-name>

                        <ejb-name>AccountEJB</ejb-name>
                        <method-name>*</method-name>



                        <ejb-name>AddressEJB</ejb-name>
                        <method-name>*</method-name>


                        </method-permission>

                        <container-transaction>

                        <ejb-name>AccountEJB</ejb-name>
                        <method-name>*</method-name>



                        <ejb-name>AddressEJB</ejb-name>
                        <method-name>*</method-name>


                        <trans-attribute>Required</trans-attribute>
                        </container-transaction>


                        </assembly-descriptor>
                        </ejb-jar>

                        • 9. Re: CMP: JDBCCreateEntityCommand.execute
                          vincent

                          Nope sorry it looks OK (sometimes people forgot prim-key-class / primkey-field the - or not pfff... )

                          2.4.1 is very old now, try 2.4.4

                          • 10. Re: CMP: JDBCCreateEntityCommand.execute
                            cook_e_monster

                            I'm using 2.4.4 and I'm experiencing exactly the same problems. Other people seem to be getting these npe's too, according to the forum. I'm gonna fiddle around a little bit more and see if I can figure it out.

                            RC

                            • 11. Re: CMP: JDBCCreateEntityCommand.execute
                              kryptontri

                              i have just tried it with 2.4.3 and the same thing happens, all other beans work fine ?
                              strange.

                              Anyway i am downloading 2.4.4 [ over a 28.8k connection ouch ] and then i will have another go.

                              Its just very strange, i also thought it was a primary key problem, but it is not.

                              I 'll do more test/mods and see what happens

                              • 12. Re: CMP: JDBCCreateEntityCommand.execute
                                cook_e_monster

                                Woohoo! I finally got my bean to work. Some of the data members of my entity bean were declared private, so I changed them to public and now my web-app runs like a charm.
                                Hope you guys get your stuff working too.

                                RC

                                • 13. Re: CMP: JDBCCreateEntityCommand.execute
                                  giles

                                  Hi there

                                  Was just trailing though the forum, and noticed you had exactly the same problem as me. Did you manage to get a solution to your null pointer exception being thrown on the ejbCreate?

                                  Any help would be great.
                                  Giles