3

I'm aware I must be missing some really basic point. The following resource method:

@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public TestObject getObj(@QueryParam("m") String m,
                         @Min(30) @NotNull @QueryParam("d") Double d) {
    return new TestObject(m,m,d);
}

works as expected in Glassfish4 (i.e returns a 400 Bad Request), but in TomEE 7.0.0-M1 (jee7) it ignores validation annotations, and responds with 200 OK. I tried setting the property (although in TomEE 7 it is set to be enabled by default), still nothing.

org.apache.openejb.default.system.interceptors = org.apache.openejb.bval.BeanValidationAppendixInterceptor

What am I missing here?

MWiesner
  • 8,868
  • 11
  • 36
  • 70
kosta
  • 296
  • 2
  • 6
  • 15

2 Answers2

0

In M1 I think you need to add @ValidateOnExecution on the method, last releases got it fixed IIRC

Romain Manni-Bucau
  • 3,354
  • 1
  • 16
  • 13
-1

You have to add @Singleton or @Stateless annotation in the JAX-RS resource for the bean validations to happen. In the case of CXF for non Singleton/non EJB resources org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInvoker needs to be registered if these objects need to be validated.

Raj
  • 115
  • 8