OptimisticLockException
JavaEE6でをキャッチするための最良の方法は何でしょうか。次のEJBがあります。
@Stateless
public class SeminarBooking {
public void bookSeminar(Long seminarId, int numberOfPersons) {
...
//check capacity & do booking
//OptimisticLockException can occur in this method
}
そしてこれは私のRESTインターフェースです:
@Path("/seminars")
@Produces("application/xml")
@Stateless
public class SeminarResource {
@GET
@Path("{id}/book")
public Seminar bookSeminar(@PathParam("id") Long id, @QueryParam("persons") Integer persons) {
try {
seminarBooking.bookSeminar(id, persons);
return seminarBooking.getSeminar(id);
}
catch(Exception e) {
//why is this never called?
logger.error(This will never happen, e);
throw new WebApplicationException(e);
}
}
RESTインターフェースでは、すべての例外をキャッチします。さらにOptimisticLockException
、ブラウザーからインターフェースを呼び出すと、catch-Blockが実行されないのはなぜですか?