title: Bean validation not working?
body: <p>I have a <code>services</code> module, with <code>ClientRequest</code> class as  </p>
  
  <pre><code>public class ClientRequest {
      @NotNull(message = "email can not be empty")
      private String email;
      @NotNull(message = "userExternalId can not be empty")
      private String userExternalId;
      @NotNull(message = "password can not be empty")
      private String password;
  
  
      @SuppressWarnings("UnusedDeclaration")
      public ClientRequest() {
          // used by jax-rs
      }
  </code></pre>
  
  <p><strong>services/pom.xml</strong> has  </p>
  
  <pre><code>&lt;properties&gt;
      &lt;validation-api.version&gt;1.1.0.Final&lt;/validation-api.version&gt;
  &lt;/properties&gt;
  
  &lt;dependency&gt;
      &lt;groupId&gt;javax.validation&lt;/groupId&gt;
      &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
      &lt;version&gt;${validation-api.version}&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I have <code>integration</code> module for writing integration tests.<br>
  <strong>integration/pom.xml</strong> looks like  </p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
      &lt;version&gt;4.0.2.GA&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
      &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
      &lt;version&gt;${slf4j-api.version}&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;  
  </code></pre>
  
  <p>and I my test looks like  </p>
  
  <pre><code>    @Test
      public void testRegisterClientInValid() throws IOException {
          final Client client = ClientBuilder.newClient();
          final Invocation.Builder request = client.target("http://localhost:9090/application/oauth/register").request(MediaType.APPLICATION_JSON);
          final Map&lt;String, String&gt; parameters = new HashMap&lt;&gt;();
          parameters.put("email", "integrationTest@gmail.com");
          final Response response = request.post(Entity.entity(parameters, MediaType.APPLICATION_JSON));
          assertEquals(HttpStatus.SC_OK, response.getStatus());
  
          final JsonNode jsonReply = getObjectMapper().readTree(response.readEntity(String.class));
          System.out.println(jsonReply);
      }  
  </code></pre>
  
  <p>Since I am expecting it to fails with <code>bean validation</code>, I see what logs has to say.  </p>
  
  <p>I see  </p>
  
  <pre><code>[INFO] [talledLocalContainer] Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
  [INFO] [talledLocalContainer]   at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:190) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3587) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:103) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:453) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:345) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1218) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:421) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  [INFO] [talledLocalContainer]   at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:110) [hibernate-core-4.3.1.Final.jar:4.3.1.Final]
  </code></pre>
  
  <p>Which means <code>bean validation</code> passed and error is at database layer because database expects a <code>not null</code> value</p>
  
  <p><strong>Question</strong><br>
  Why is bean validation not working, what is that I am doing wrong here?</p>