Discussions

EJB programming & troubleshooting: VERY VERY URGENT!! ejbStore() throwing exceptions

  1. I have a table named GL_CHART_OF_ACCOUNT having a
    compound primary key(account_ref_id,company_code).
    The above PK is also a foreign key in the same table
    (self relationship).
    The relationship is one to many.
    I have made an entity bean representing the above table.
    I have an abstract method
    "setGL_CHART_OF_ACCOUNT(GL_CHART_OF_ACCOUNT cAccount)"
    for updating a relation.
    GL_CHART_OF_ACCOUNT is an EjbObject.

    Now I am updating a row

    First I call cAccounts=ejbFindByPrimaryKey(new com.gl.beans.GL_CHART_OF_ACCOUNT_PK(account_ref_id,company_code)).

    It returns the remote interface.

    when I update a row and call setGL_CHART_OF_ACCOUNT(cAccount)
    it throws

    Remote Exception EJB Exception: ; nested exception is:
    weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync = weblogic.ejb20.internal.TxManager$TxListener@1b300d85

    Error writing from beforeCompletion - with nested exception:

    [weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion - with nested exception:

    [java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityException: Bean with primary key: com.gl.beans.GL_CHART_OF_ACCOUNT_PK@16809c not found.]]

    How do i fix it please give me the response........?
    During entity creation it is working fine

    I am using weblogic6.0Sp2 with EJB2.0

  2. Since it has foriegn key relationship, check whether the row exists for all the values you enter for one to many relations(if you enter five rows for each row you get from findByPrimaryKey, make sure the five rows you are about to enter already exists as primary key).
    ObjectNotFoundException is thrown if a row is not present(when you do fingByMethod)
  3. foreign keys are avaliable for all the values(account_ref_id,company_code).
    actualy the row which it says not found is the parent row which i am trying to update and it 100% exists.
    The adminstation tool of weblogic server also shows that the row is present in the cache.
    my code is
    ************************************************************
    public void updateChartOfAccounts(Integer accountRefId,String companyCode,String accountCode,String accountDesc,String accountNo,String basis,String accountLevel,String accountNature,String timeStamp,String parentCompanyCode,String parentAccountCode) throws RemoteException,FinderException,AccountCodeNotExistsException,CompanyNotExistsException,RecordHasBeenUpdatedException,ParentAccountCodeNotExistsException,NoSuchObjectException
    {
      GL_CHART_OF_ACCOUNT glChartOfAccount = null; lookupCompanyHome();
         lookupChartOfAccountHome();
    try
    {
    //Find Remote Interface of the Parent ChartOfAccount Row
    if (parentCompanyCode.equals("") == false)
    {
    try
    {
    glParentChartOfAccount = glChartOfAccountHome.findByCompany_CodeAndAccount_Code(parentCompanyCode,parentAccountCode);
    }
                 catch(javax.ejb.FinderException ex)
                 {
          log("GL_CHART_OF_ACCOUNT_SESSION_EJB.updateChartOfAccounts() ParentAccountCodeNotExists Exception........................... ");
                 throw new ParentAccountCodeNotExistsException ("Record1:Parent Account Code "+parentAccountCode+" Not Exists for Company "+parentCompanyCode);
                 }
    }
    else
    {
    glParentChartOfAccount = null;
                 }
    //Find Remote Interface of the Current ChartOfAccount Row
    try
    {
    glChartOfAccount = glChartOfAccountHome.findByCompany_CodeAndAccount_Code(companyCode,accountCode);
    }
    catch(javax.ejb.FinderException ex)
                 {
                 throw new AccountCodeNotExistsException ("Record1:Account Code Not Exists for Company "+companyCode);
                 }
    Find Remote Interface of the Company Row
    try
    {
    glCompany= glCompanyHome.findByPrimaryKey(companyCode);
    }
                 catch(javax.ejb.FinderException ex)
                 {
                 throw new CompanyNotExistsException ("Record1:Company Not Exists");
                 }

    glChartOfAccount.setAccount_Code(accountCode);
      glChartOfAccount.setAccount_Desc(accountDesc);
    glChartOfAccount.setAccount_No(accountNo);
    glChartOfAccount.setBasis(basis);
    glChartOfAccount.setAccount_Level(accountLevel);
      glChartOfAccount.setAccount_Nature(accountNature);
    glChartOfAccount.setGL_CHART_OF_ACCOUNT(glParentChartOfAccount);
      glChartOfAccount.setTimeStamp(new java.sql.Timestamp(new java.util.Date().getTime()));
    }
    catch(java.rmi.RemoteException ex)
    {
          log("GL_CHART_OF_ACCOUNT_SESSION_EJB.updateChartOfAccounts() RemoteException........................... ");
                 log(ex.getMessage());
    }
    catch(Exception ex)
    {
          log("GL_CHART_OF_ACCOUNT_SESSION_EJB.updateChartOfAccounts() Exception........................... ");
                 log(ex.getMessage());
    }
    }
    **********************************************************
    glChartOfAccount.setGL_CHART_OF_ACCOUNT(glParentChartOfAccount);

    the above method is throwing the exception



    <Jun 22, 2000 1:34:34 AM GMT+05:00> <Error> <EJB> <Exception during commit of transaction transaction=(IdHash=3428656,Name = [EJB GL_CHART_OF_ACCOUNT_SESSION_EJBImpl.updateChartOfAccounts()],Xid=289:b37b632e804b4999,Status=Rolled back. [Reason = weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion - with nested exception:
    [java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityException: Bean with primary key: 'com.gl.beans.GL_CHART_OF_ACCOUNT_PK@168c09' not found.]],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=30,SCInfo[myserver]=(state=rolledback),properties=({weblogic.transaction.name=[EJB GL_CHART_OF_ACCOUNT_SESSION_EJBImpl.updateChartOfAccounts()]})): java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityException: Bean with primary key: 'com.gl.beans.GL_CHART_OF_ACCOUNT_PK@168c09' not found.
            at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:57)
            at weblogic.ejb20.manager.DBManager.beforeCompletion(DBManager.java:364)
            at weblogic.ejb20.internal.TxManager$TxListener.beforeCompletion(TxManager.java:211)
            at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:511)
            at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:78)
            at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:893)
            at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1229)
            at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:168)
            at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:201)
            at com.gl.beans.GL_CHART_OF_ACCOUNT_SESSION_EJBEOImpl.updateChartOfAccounts(GL_CHART_OF_ACCOUNT_SESSION_EJBEOImpl.java:80)
            at client.gl.beans.ChartOfAccountBean.editChartOfAccount(ChartOfAccountBean.java:107)
            at client.gl.beans.ChartOfAccountBean.processRequest(ChartOfAccountBean.java:64)
            at jsp_servlet._chartofaccountscontroller._jspService(_chartofaccountscontroller.java:240)
            at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
            at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1631)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)