title: How to catch OptimisticLockException in JavaEE 6?
body: <p>I wonder what is the best way to catch an <code>OptimisticLockException</code> in JavaEE 6. I have the following EJB:</p>
  
  <pre><code>@Stateless
  public class SeminarBooking {
  
  public void bookSeminar(Long seminarId, int numberOfPersons) {
      ...
      //check capacity &amp; do booking
      //OptimisticLockException can occur in this method
  }
  </code></pre>
  
  <p>And this is my REST interface:</p>
  
  <pre><code>@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);
          }
  }
  </code></pre>
  
  <p>In the REST interface I catch all Exceptions, furthermore I see the <code>OptimisticLockException</code> if I call the interface from the browser, so why is the catch-Block never executed? </p>