[wildfly-dev] Handling @TransactionAttribute exceptions

Gytis Trikleris gytis at redhat.com
Fri Jul 26 07:37:28 EDT 2013


I have a bridge which creates JTA transaction if REST-AT transaction 
context is available during REST request. Therefore, JAX-RS resources 
can use @TransactionAttribute annotations. Example of such resource is 
here: http://tinyurl.com/pf6c7hu.

If REST-AT transaction does not exist during the request to 
transactionAttributeMandatory() - EJBTransactionRequiredException is 
thrown.

If REST-AT transaction does exist during the request to 
transactionAttributeNever() - EJBException with the follwing message is 
thrown: "JBAS014163: Transaction present on server in Never call (EJB3 
13.6.2.6)".

To handle those exceptions I have an ExceptionMapper which returns 
appropriate HTTP responses: http://tinyurl.com/q4v54ph. In the mapper I 
can easily look for EJBTransactionRequiredException. But in case of 
EJBException I am looking for JBAS014163 code. I wanted to ask if it is 
safe to rely on looking for error code? Or maybe there is a better option?

Thanks,
Gytis

On 26/07/13 14:08, Scott Marlow wrote:
> Can you give more context here, the full exception call stack would be 
> helpful (please post a pastebin.com link or something like that).
>
> On 07/26/2013 06:10 AM, Gytis Trikleris wrote:
>> Hello,
>>
>> I need to handle exception when either
>> TransactionAttributeType.MANDATORY or TransactionAttributeType.NEVER
>> requirement is not met. It is not a problem for MANDATORY, because
>> EJBTransactionRequiredException is thrown. However, general EJBException
>> exception is thrown if unexpected transaction was on the thread.
>>
>> I wanted to ask what is the best way to detect that EJBException was
>> caused because of unnecessary transaction? Error code given by the
>> exception is JBAS014163, but I am not sure if it is safe to rely on
>> message codes...
>>
>> Thanks,
>> Gytis
>> _______________________________________________
>> wildfly-dev mailing list
>> wildfly-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/wildfly-dev/attachments/20130726/ea7a8836/attachment.html 


More information about the wildfly-dev mailing list