Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-10958

Exception info. is not logged when using AsyncUtils to call EJB service

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • EAP_EWP 5.3.0.GA
    • EAP_EWP 5.1.2
    • EJB
    • None
    • JBoss EAP 5.1.2

    • Hide

      Use following provided class as EJB service and deploy it on EAP 5.1.2.
      Invoke startTest() method via EAP 5 JMX Console.

      By calling asyncNullJob(), a "NullPointerException" is expected to be logged on server side, but there is nothing in the log.

      Further investigation indicates that in FutureTask$Sync.innerRun() it does this with the exception:
      �� try

      { result = callable.call(); �� }

      catch (Throwable ex)

      { �� setException(ex); return; �� }

      set(result);
      Sets it in a sync object which would be why we can get it later with the Future. So to see the exception in the log when no FutureResult is called we would have to modify that org.jboss.ejb3.common.proxy.plugins.async.AsyncInterceptor$AsyncTask.call() method.

      ================================================
      import java.util.concurrent.atomic.AtomicInteger;

      import javax.ejb.TransactionManagement;
      import javax.ejb.TransactionManagementType;

      import org.jboss.ejb3.annotation.LocalBinding;
      import org.jboss.ejb3.annotation.Service;
      import org.jboss.ejb3.common.proxy.plugins.async.AsyncUtils;
      import org.jboss.logging.Logger;

      @Service(objectName = "com.company.async:service=AsyncTestService")
      @LocalBinding(jndiBinding = "com.company.async.AsyncProcessorLocal")
      @TransactionManagement(TransactionManagementType.BEAN)
      public class AsyncTestService implements AsyncTest, AsyncProcessorLocal {

      /**

      • Logger.
        */
        private final Logger L = Logger.getLogger(this.getClass().getSimpleName());

      /**

      • The asynchronous version of this interface.
        */
        private AsyncProcessorLocal asyncLocal = null;

      /**

      • Counter of the number of running contexts.
        */
        public static AtomicInteger runningCounter = new AtomicInteger(0);

      @Override
      public String start() throws Exception

      { L.info("AsyncTestService.start() called"); asyncLocal = AsyncUtils.mixinAsync((AsyncProcessorLocal) this); return "AsyncTestService.start() called"; }

      @Override
      public String stop() throws Exception

      { L.info("AsyncTestService.stop() called"); return "AsyncTestService.stop() called"; }

      @Override
      public String startTest() throws Exception

      { L.info("AsyncTestService.startTest() called"); int original = runningCounter.get(); asyncLocal.asyncJob(); Thread.currentThread().sleep(2000); int afterJob = runningCounter.get(); // This should be 0 and it is 0 asyncLocal.asyncNullJob(); Thread.currentThread().sleep(2000); int afterNullJob = runningCounter.get(); // This should be 0 but becomes // 1. runningCounter = new AtomicInteger(0); // After four seconds this will be printed out // "Concurrent Job: original >> 0, after job >> 0, after null job >> 1" return "Concurrent Job: original >> " + original + ", after job >> " + afterJob + ", after null job >> " + afterNullJob; }

      @Override
      public void asyncJob()

      { runningCounter.incrementAndGet(); Job job = new Job(); job.doJob(); runningCounter.decrementAndGet(); }

      @Override
      public void asyncNullJob()

      { runningCounter.incrementAndGet(); Job job = null; job.doJob(); // I am expecting NullPiontException but thread just // silently dropped. // As a result, the counter is not decrement. runningCounter.decrementAndGet(); }

      }

      class Job {
      public void doJob()

      { return; }

      }

      ==============================================

      Show
      Use following provided class as EJB service and deploy it on EAP 5.1.2. Invoke startTest() method via EAP 5 JMX Console. By calling asyncNullJob(), a "NullPointerException" is expected to be logged on server side, but there is nothing in the log. Further investigation indicates that in FutureTask$Sync.innerRun() it does this with the exception: �� try { result = callable.call(); �� } catch (Throwable ex) { �� setException(ex); return; �� } set(result); Sets it in a sync object which would be why we can get it later with the Future. So to see the exception in the log when no FutureResult is called we would have to modify that org.jboss.ejb3.common.proxy.plugins.async.AsyncInterceptor$AsyncTask.call() method. ================================================ import java.util.concurrent.atomic.AtomicInteger; import javax.ejb.TransactionManagement; import javax.ejb.TransactionManagementType; import org.jboss.ejb3.annotation.LocalBinding; import org.jboss.ejb3.annotation.Service; import org.jboss.ejb3.common.proxy.plugins.async.AsyncUtils; import org.jboss.logging.Logger; @Service(objectName = "com.company.async:service=AsyncTestService") @LocalBinding(jndiBinding = "com.company.async.AsyncProcessorLocal") @TransactionManagement(TransactionManagementType.BEAN) public class AsyncTestService implements AsyncTest, AsyncProcessorLocal { /** Logger. */ private final Logger L = Logger.getLogger(this.getClass().getSimpleName()); /** The asynchronous version of this interface. */ private AsyncProcessorLocal asyncLocal = null; /** Counter of the number of running contexts. */ public static AtomicInteger runningCounter = new AtomicInteger(0); @Override public String start() throws Exception { L.info("AsyncTestService.start() called"); asyncLocal = AsyncUtils.mixinAsync((AsyncProcessorLocal) this); return "AsyncTestService.start() called"; } @Override public String stop() throws Exception { L.info("AsyncTestService.stop() called"); return "AsyncTestService.stop() called"; } @Override public String startTest() throws Exception { L.info("AsyncTestService.startTest() called"); int original = runningCounter.get(); asyncLocal.asyncJob(); Thread.currentThread().sleep(2000); int afterJob = runningCounter.get(); // This should be 0 and it is 0 asyncLocal.asyncNullJob(); Thread.currentThread().sleep(2000); int afterNullJob = runningCounter.get(); // This should be 0 but becomes // 1. runningCounter = new AtomicInteger(0); // After four seconds this will be printed out // "Concurrent Job: original >> 0, after job >> 0, after null job >> 1" return "Concurrent Job: original >> " + original + ", after job >> " + afterJob + ", after null job >> " + afterNullJob; } @Override public void asyncJob() { runningCounter.incrementAndGet(); Job job = new Job(); job.doJob(); runningCounter.decrementAndGet(); } @Override public void asyncNullJob() { runningCounter.incrementAndGet(); Job job = null; job.doJob(); // I am expecting NullPiontException but thread just // silently dropped. // As a result, the counter is not decrement. runningCounter.decrementAndGet(); } } class Job { public void doJob() { return; } } ==============================================
    • Release Notes
    • Workaround Exists
    • Hide

      Try to use try / catch in EJB service end method, to catch all exceptions and pint the info. / stackTrace

      Show
      Try to use try / catch in EJB service end method, to catch all exceptions and pint the info. / stackTrace
    • Not Yet Documented
    • NEW

      When using asynchronous proxy to call an EJB, and if there is exception happens during the EJB method execution, no exception info. / stackTrace will be printed in the log if the client doesn't request future results.

      This only happens when:
      1) No try / catch statements to catch server side exceptions in EJB method
      2) Client doesn't use AsyncUtils.getFutureResult() to wait for a future return after the invocation on EJB method.

              jboss-set_jira JBoss SET
              rhn-support-lywang Lyle Wang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: