WebApplicationException contract could clarify behaviour related to JTA resources
- Dominant language
- Java
- Stars
- 400
- Forks
- 143
- PR merge metrics
- No merged PRs in 30d
Description
This is based on [JERSEY-2137](https://java.net/jira/browse/JERSEY-2137 "Unable to throw WAE from a @Transactional JAX-RS resource.") ([GLASSFISH-20699](https://java.net/jira/browse/GLASSFISH-20699 "GlassFish returns 500 instead of 404 upon WebApplicationException") respectively).
If a WebApplicationException is thrown from a resource method belonging to a @Transactional annotated JAX-RS component,
it is not clear if the WebApplicationException should drive the response and JTA runtime should be worked around,
or (based on the JTA spec) the exception should be handled by JTA runtime instead (transaction would be rolled back,
etc, see: [https://javaee-spec.java.net/nonav/javadocs/javax/transaction/Transactional.html](https://javaee-spec.java.net/nonav/javadocs/javax/transaction/Transactional.html)).
Maybe this could be clarified in the JAX-RS spec.
Currently one way to avoid WebApplicationException to cause rollback is to use the dontRollbackOn parameter on the @Transactional annotation.
I.e. the following should provide a predictable result:
```
@RequestScoped
@Path("test")
@Transactional(dontRollbackOn=WebApplicationException.class)
public class MyTransactionalService {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String get() {
...
}
}
```
#### Affected Versions
[2.1]
Contributor guide
Assessment
This issue has not been assessed yet.