Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-5497

Exception handling of EJB container for MDB is incorrect

XMLWordPrintable

    • Hide

      I have tested with this simple RA:
      https://github.com/nekop/twitter-resource-adapter/

      where you need to add equals,hashcode methods to
      TwitterResourceAdapter. Next thing to make this work is to add
      under <subsystem xmlns="urn:jboss:domain:ejb3:1.3"> in standalone.xml:

      <mdb>
      <resource-adapter-ref
      resource-adapter-name="twitter-ra"/>
      <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
      </mdb>

      So I added to TwitterActivation.run() at the end
      throw new RuntimeException("TESTING RUNTIME EXCEPTION");

      To deploy:
      [standalone@localhost:9999 /]
      deploy /home/adam/gss-devel/twitter-resource-adapter/ra/target/twitter-ra.rar
      --force [standalone@localhost:9999 /]
      deploy /home/adam/gss-devel/twitter-resource-adapter/impl/target/twitter-ra-impl-0.1.jar
      --force [standalone@localhost:9999 /]
      deploy /home/adam/gss-devel/twitter-resource-adapter/example/target/twittermdb.jar
      --force

      After deploying this, log shows:
      11:01:36,941 ERROR [stderr] (Timer-4) Exception in thread "Timer-4"
      java.lang.RuntimeException: TESTING RUNTIME EXCEPTION 11:01:36,941
      ERROR [stderr] (Timer-4) at
      jp.programmers.resource.adapter.twitter.inflow.TwitterActivation.run(TwitterActivation.java:114)
      11:01:36,941 ERROR [stderr] (Timer-4) at
      java.util.TimerThread.mainLoop(Timer.java:512) 11:01:36,941 ERROR
      [stderr] (Timer-4) at java.util.TimerThread.run(Timer.java:462)

      Which seems to confirm that the Exception is not wrapped as
      EJBException.

      Show
      I have tested with this simple RA: https://github.com/nekop/twitter-resource-adapter/ where you need to add equals,hashcode methods to TwitterResourceAdapter. Next thing to make this work is to add under <subsystem xmlns="urn:jboss:domain:ejb3:1.3"> in standalone.xml: <mdb> <resource-adapter-ref resource-adapter-name="twitter-ra"/> <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> </mdb> So I added to TwitterActivation.run() at the end throw new RuntimeException("TESTING RUNTIME EXCEPTION"); To deploy: [standalone@localhost:9999 /] deploy /home/adam/gss-devel/twitter-resource-adapter/ra/target/twitter-ra.rar --force [standalone@localhost:9999 /] deploy /home/adam/gss-devel/twitter-resource-adapter/impl/target/twitter-ra-impl-0.1.jar --force [standalone@localhost:9999 /] deploy /home/adam/gss-devel/twitter-resource-adapter/example/target/twittermdb.jar --force After deploying this, log shows: 11:01:36,941 ERROR [stderr] (Timer-4) Exception in thread "Timer-4" java.lang.RuntimeException: TESTING RUNTIME EXCEPTION 11:01:36,941 ERROR [stderr] (Timer-4) at jp.programmers.resource.adapter.twitter.inflow.TwitterActivation.run(TwitterActivation.java:114) 11:01:36,941 ERROR [stderr] (Timer-4) at java.util.TimerThread.mainLoop(Timer.java:512) 11:01:36,941 ERROR [stderr] (Timer-4) at java.util.TimerThread.run(Timer.java:462) Which seems to confirm that the Exception is not wrapped as EJBException.
    • Workaround Exists

      After deploying a MDB with Container-Managed transaction and
      TransactionAttribute NOT_SUPPORTED, a RuntimeException thrown from
      within the MDB onMessage() is reported to the Adapter as such, with no
      EJBException wrapping. I.e.: the "((javax.jms.MessageListener)
      endPoint).onMessage(message)" call in our adapter fails with the
      exception type originally thrown.

      This does not look compliant with EJB 3.1 spec(JSR 318: Enterprise
      JavaBeansTM, Version 3.1, Table 20 page 392, last cell bottom right):
      "Throw EJBException that wraps the original exception to resource
      adapter".

      Another part of spec I was just made aware of says this:

      p383 of the spec states -

      In the case of a message-driven bean, the container logs the exception and then throws a javax.ejb.EJBException that wraps the original exception to the resource adapter. (See [15]).

              jboss-set_jira JBoss SET
              adam.kovari Adam Kovari (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: