[wildfly-dev] Handling @TransactionAttribute exceptions

Michael Musgrove mmusgrov at redhat.com
Fri Jul 26 08:02:17 EDT 2013


Error and warning messages must have a unique code that can be used to 
identify them (https://issues.jboss.org/browse/ANDIAMO-7) so JBAS014163 
will always refer to that error. The only thing you would need to be 
careful of is if a more specific code were created and that was 
generated instead. But you should be able to catch that in your 
integration tests.

Mike

> 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,
> GytisOn 26/07/13 12:37, Gytis Trikleris wrote:
>
> 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
>>>
>>
>
>
>
> _______________________________________________
> 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/dc12ff46/attachment.html 


More information about the wildfly-dev mailing list