0 Replies Latest reply on Oct 30, 2002 12:37 PM by jcasp

    handling NoSuchObjectLocalException?

    jcasp

      Hi,
      I can't seem to figure out why I can't catch certain EJBExceptions in my code. I have a collection of local entities that are children in a one-to-many CMR. If I try to call the child's parent accessor and then a method on the parent bean, I get a NoSuchObjectLocalException if the parent record is missing in the DB. I expect this, and it's no problem. However, I can't seem to catch this exception and move on with the rest of the children iteration. A TransactionRolledbackLocalException is thrown as a result of the missing parent, which invalidates any further operations on my collection.

      Am I missing something obvious here? I'm out of ideas, so any advice is highly appreciated.
      Justin

      here is a bit of the code:

      LocalCSRequest csr = (LocalCSRequest)i.next();
      ...
      CSRViewObject vo = new CSRViewObject();
      ...
      try {
      LocalJob job = csr.getJob(); //** parent accessor **
      vo.job = job.getJobID(); //** exception thrown here **
      }
      // ** this is not caught **
      catch(EJBException e) {
      System.err.println("No Job entity found for csr");
      }
      return vo;

      stack trace:

      ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
      javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=21026
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:181)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy694.getJobID(Unknown Source)
      at com.wavespring.cs.ejb.session.CSRequestViewerBean.createCSRViewFromEntity(CSRequestViewerBean.java:321)