Jersey ModelValidationException - No Injection source found
SomeValueDTO
needs to be convertible. Options to accomplish this:
- A
public static SomeValueDTO valueOf(String param)
that returns the type (SomeValueDTO) - A
public static SomeValueDTO fromString(String param)
that returns the type (SomeValueDTO) - Or a public constructor that accepts a String
- Implement a
ParamConverter
. You can see an example here
In either of the first three cases, you'll want to construct the instance accordingly by parsing the String either in the constructor or in one of the above-mentioned methods.
Generally, you'll only want to use the ParamConverter
for third-party classes that you cannot edit. Otherwise use the other three options for your own classes.
From Jersey 2.0, you can use @BeanParam
as input but you must set all @QueryParam
in the DTO variables:
@ApiOperation("Save")
@PUT
public Response save(@BeanParam SomeValueDTO inputValue)
{
String prop1 = inputValue.prop1;
String prop2 = inputValue.prop2;
String prop3 = inputValue.prop3;
}
SomeValueDTO.java
will be:
public class SomeValueDTO{
@QueryParam("prop1")
public String prop1;
@QueryParam("prop2")
public String prop2;
@QueryParam("prop3")
public String prop3;
}
The http call can be:
$http.get('insert-path', {
params: {
prop1: "prop1value",
prop2: "prop2value",
prop3: "prop3value"
}});
Source answer: https://stackoverflow.com/a/17309823/3410465