Java EE: @ApplicationException throws, still rolls back transactions

I need some direction on how to best use exceptions in the Java EE environment, serving clients through JAX-RS.

I currently have a number of exceptions, all expanding RuntimeExceptionand annotated with help @ApplicationException(rollback=false). To pass them on to customers, they carry an annotated JAXB object; and I ExceptionMapper’m ready to convert them to appropriate, meaningful HTTP responses (HTTP status codes are included).

I haven't said anything about transactional behavior, so I think it defaults to CMT.

Great stuff: when the server decides, it cannot fulfill the request, because the input data is invalid / sufficient / not, it throws one of mine BadRequestException, which makes it a JAX-RS resource, where it maps to the HTTP response. The client is informed about what went wrong.

Problem I have what I always get javax.ejb.TransactionRolledbackLocalExceptioncalled BadRequestException! I do not want the transaction to be canceled! The @ApplicationException is ignored ...

Should I not propagate from RuntimeException, but use checked exceptions? I though @ApplicationException should have been the right way ...

For reference: all of my Exceptions leave the container / beans operational. No need to destroy the bean instance or something like that.

+3
2

, , :).

An @ApplicationException a RuntimeException. RuntimeExceptions , bean, ..

, IDE . . , ApplicationException .

, Bea Weblogic.

+1

, : Annotation @ApplicationException ( / ), ejb-jar. , ApplicationException java- API. XML ApplicationException.

https://www.java.net//node/665096

+4

All Articles