4 Replies Latest reply on Dec 2, 2001 12:17 PM by kryptontri

    CMP : finder : id null

    kryptontri

      Problem:

      I have an ejb - AccountEJB deployed - all methods work fine apart from a findByUserName. I have searched the forum and cannot find any similar problems.

      StackTrace:
      [AccountEJB] TRANSACTION ROLLBACK EXCEPTION:null
      Embedded Exception
      null; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      null
      [AccountEJB] java.lang.NullPointerException
      [AccountEJB] at org.jboss.ejb.plugins.jrmp13.server.JRMPContainerInvoker.getEntityCollection(JRMPContainerInv
      oker.java:132)
      [AccountEJB] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.getEntityCollection(JRMPContainerInvok
      er.java:353)
      [AccountEJB] at org.jboss.ejb.EntityContainer.find(EntityContainer.java:570)
      [AccountEJB] at java.lang.reflect.Method.invoke(Native Method)
      [AccountEJB] at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:843)
      [AccountEJB] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterc
      eptor.java:231)
      [AccountEJB] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:154
      )
      [AccountEJB] at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:108)
      [AccountEJB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
      [AccountEJB] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:307)
      [AccountEJB] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
      [AccountEJB] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:103)
      [AccountEJB] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
      [AccountEJB] at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:420)
      [AccountEJB] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:3
      72)
      [AccountEJB] at java.lang.reflect.Method.invoke(Native Method)
      [AccountEJB] at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
      [AccountEJB] at sun.rmi.transport.Transport$1.run(Unknown Source)
      [AccountEJB] at java.security.AccessController.doPrivileged(Native Method)
      [AccountEJB] at sun.rmi.transport.Transport.serviceCall(Unknown Source)
      [AccountEJB] at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
      [AccountEJB] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
      [AccountEJB] at java.lang.Thread.run(Unknown Source)
      -----------------------------------------------------

      Home Interface

      /**
      * Search account by UserName
      */
      public Account findByUserName(String userName)
      throws FinderException, RemoteException;

      -----------------------------------------------------
      AccountEJB Impl

      /**
      * Accessor method ejbFindByUserName retrieves a single Account by using its username
      *
      * @param String - The account username to search on
      * @return Integer- The account id to load
      * @throws RemoteException
      * @throws FinderException
      */
      public Integer ejbFindByUserName(String userName)
      throws FinderException, RemoteException {

      if ( log.isDebugEnabled() ) {
      log.debug("ejbFindByUserName - " + userName);
      }

      return null;
      }

      -------------------------------------------------
      Jaws xml

      <?xml version="1.0" encoding="UTF-8"?>

      java:/HypersonicDS
      <type-mapping>Hypersonic SQL</type-mapping>
      true

      <default-entity>
      <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>
      </default-entity>

      <enterprise-beans>


      <ejb-name>AccountEJB</ejb-name>
      <table-name>Account</table-name>
      <create-table>false</create-table>


      <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>


      findByUserName
      userName = {0}

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





      </enterprise-beans>



      -----------------------------------------------------

      DB schema:

      create table Account(

      AccountId int not null,
      AccountName varchar(255) null,
      CardType varchar(30) null,
      CardNumber varchar(16) null,
      SortCode varchar(8) null,
      ExpiryDate varchar(30) null,
      CreationDate datetime null,
      LastLogin datetime null,
      AccountDisabled varchar(10) null,
      Username varchar(15) null,
      Password varchar(15) null,

      constraint PK_Account primary key(AccountId)

      )
      ;

      -------------------------------------------------
      Summary:

      All business methods work e.g setXX etc, findByPrimaryKey work and aswell as findAll ...

      but when i invoke findByUserName(String name) there is a failure and i do not know why jboss has a stack trace refering to id. Could this be an id in the cache ?

      Many Thanks If you can help

        • 1. Re: CMP : finder : id null
          kryptontri

          continued ...

          this is the top part of the stack trace

          [AccountEJB] setEntityContext
          [AccountEJB] ejbFindByUserName - raj
          [AccountEJB] TRANSACTION ROLLBACK EXCEPTION:null
          Embedded Exception
          null; nested exception is:
          javax.ejb.EJBException: null
          Embedded Exception
          null
          [AccountEJB] java.lang.NullPointerException
          [AccountEJB] at org.jboss.ejb.plugins.jrmp13.server.JRMPContainerInvoker.getEntityCollection(JRMPContainerInv
          oker.java:132)
          [AccountEJB] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.getEntityCollection(JRMPContainerInvok
          er.java:353)
          [AccountEJB] at org.jboss.ejb.EntityContainer.find(EntityContainer.java:570)

          I have tried to change names around, the case, returning a collection instead of a single account object, yet this still occurs ? is there some basic error on my part ?

          • 2. Re: CMP : finder : id null
            kryptontri

            sorry forgot to mention this was on 2.4.1 AND 2.4.3 ... still the same results

            • 3. Re: CMP : finder : id null
              quennie

              instead of userName (CMP field) use the Username (dataase field) n your finders.

              • 4. Re: CMP : finder : id null
                kryptontri

                after having read more docs it seems this is an error on my part. There was no need for me to even declare an empty implementation in my EJB class, there has to be a finder declared in the Home and after editing the jaws correctly it works fine now.

                It seems that if you wish to overide the finder - ie create a custom finder you need then declare the finder in the EJB and provide implementation.

                Thanks anyway ..

                happy hacking :)