Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 900803 (JBPAPP6-1355)

Summary: Exception handling of EJB container for MDB is incorrect
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Adam Kovari <akovari>
Component: EJBAssignee: Chao Wang <chaowan>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0.0CC: akovari, cdewolf, jmartisk, nicolas.strauel, nobody
Target Milestone: ---   
Target Release: EAP 6.1.0   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/JBPAPP6-1355
Whiteboard: eap6 ejb3.1
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
JBoss EAP 6.0.0
Last Closed: 2013-07-23 18:35:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
twitter-resource-adapter.zip none

Description Adam Kovari 2012-08-21 12:48:27 UTC
Help Desk Ticket Reference: https://c.na7.visual.force.com/apex/Case_View?id=500A000000AsqKf
Steps to Reproduce: 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: Workaround Exists
project_key: JBPAPP6

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]).

Comment 1 Adam Kovari 2012-08-21 12:51:43 UTC
reproducer

Comment 2 Adam Kovari 2012-08-21 12:51:43 UTC
Attachment: Added: twitter-resource-adapter.zip


Comment 3 Carlo de Wolf 2012-08-21 12:59:00 UTC
Security: Added: Public
Docs QE Status: Added: NEW


Comment 4 Adam Kovari 2012-09-04 09:27:35 UTC
simple patch to wrap exception as EJBException. Not really sure how much it breaks

Comment 5 Adam Kovari 2012-09-04 09:27:35 UTC
Attachment: Added: JBPAPP-9720_simple.patch


Comment 6 Carlo de Wolf 2012-09-04 09:43:55 UTC
It doesn't take into account whether it is an ApplicationException or not.

Comment 7 Adam Kovari 2012-09-04 12:26:37 UTC
Attachment: Added: JBPAPP-9720_simple2.patch


Comment 8 Adam Kovari 2012-09-04 12:29:46 UTC
Attachment: Removed: JBPAPP-9720_simple2.patch 


Comment 9 Adam Kovari 2012-09-04 12:30:09 UTC
Attachment: Added: JBPAPP-9720_simple2.patch


Comment 10 Adam Kovari 2012-09-04 14:48:12 UTC
Git Pull Request: Added: https://github.com/jbossas/jboss-as/pull/3002


Comment 11 Adam Kovari 2012-09-04 14:49:07 UTC
Attachment: Removed: JBPAPP-9720_simple2.patch 


Comment 12 Adam Kovari 2012-09-04 14:49:12 UTC
Attachment: Removed: JBPAPP-9720_simple.patch 


Comment 13 Adam Kovari 2012-09-04 14:49:33 UTC
Removed previous patches, they were wrong, added git pull request with a new patch.

Comment 14 Adam Kovari 2012-09-05 07:10:45 UTC
Link: Added: This issue Cloned to JBPAPP-9819


Comment 15 Adam Kovari 2012-09-06 07:20:12 UTC
Link: Added: This issue Cloned to JBPAPP-9833


Comment 16 Adam Kovari 2012-09-06 07:24:05 UTC
Link: Removed: This issue Cloned to JBPAPP-9819 


Comment 17 Adam Kovari 2012-09-06 07:24:17 UTC
Link: Added: This issue relates to JBPAPP-9819


Comment 18 Adam Kovari 2012-09-07 08:53:50 UTC
Link: Removed: This issue relates to JBPAPP-9819 


Comment 19 Anne-Louise Tangring 2012-11-13 20:57:48 UTC
Docs QE Status: Removed: NEW 


Comment 20 Chao Wang 2012-12-12 11:18:12 UTC
I see the PR has been merged to eap-master branch, tested and no more ERROR as description.

Comment 21 Jan Martiska 2013-03-29 07:36:18 UTC
verified in 6.1.0.ER3