I'm developing a Dropwizard app and am facing a strange bug on a GET request after I have included mongojack.
I have a simple GET query with the ID as a path parameter. It worked before I included mongojack and added two annotations to my entity:
public class Bill {
@javax.persistence.Id @org.mongojack.ObjectId
private String id;
@javax.persistence.Id @org.mongojack.ObjectId
public String getId() { return id; }
//...
}
What puzzles me most is that the request is actually accepted. When I debug, I can step into the method. The entity is loaded from MongoDB into memory and looks fine. So I suspect that this might actually be serialization issue, but currently I'm stuck. Any ideas?
Update
Seems to be a known mongojack issue: https://github.com/devbliss/mongojack/issues/26. Later I want to use custom DTOs without ObjectIds for my GETs anyway, so this shouldn't be relevant anymore. What I still don't understand is why Dropwizard maps this to a 400 response...
What I still don't understand is why Dropwizard maps this to a 400 response
Dropwizard, via Jackson, generates JSON using all the getters (or @JsonProperty
annotated fields/methods) as you know. If any exception occurs on getters (or setters on deserialization) dropwizard automatically returns 400 Bad Request
.
I guess that makes sense since it expects simple POJO DTOs with dumb getters and setters.