I have a simple JAX-RS InvoiceResource with an injected bean:
@Path("invoices")
public class InvoiceResource {
@Inject
private InvoiceStore invoiceDao;
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response create(@Context UriInfo uri, InvoiceDto invoiceDto) {
I wanted to add validation of the InvoiceDto I'm recieving, so I added an annotation:
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response create(@Context UriInfo uri, @Valid InvoiceDto invoiceDto) {
Now it seems that this breaks CDI. I start to get the following error:
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=InvoiceStore,parent=InvoiceResource,qualifiers={})
I was expecting a validation exception istead. What am I doing wrong? I'm using glassfish 4 web profile, and if I understood correctly applying validation to params is part of Java EE 7 CDI 1.1 spec.