You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm not sure, that is bug, but by default JacksonJsonProvider.class not registrated in JerseyConfiguration module.
I have situation:
Simple controller:
@Path("/version")
public class VersionController {
private ApplicationInfo applicationInfo;
@Inject
public VersionController(ApplicationInfo applicationInfo) {
this.applicationInfo = applicationInfo;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public ApplicationInfo getInfo() {
return applicationInfo;
}
}
where ApplicationInfo is POJO binded as singleton with @singleton annotation.
I run in IDE, go to /version endpoint — all goes good.
I build package with maven, run it and get error MessageBodyWriter not found for media type=application/json, type=class com.my.package.ApplicationInfo, genericType=class com.my.package.ApplicationInfo.
Other mime-types work fine.
I found solution. It's necessary to manual register JacksonJsonProvider.class in JerseyConfiguration:
We didn't necessarily wanted to the change the defaults provided by Jersey it self, as it become more opinionated. Maybe some people like GSON better than Jackson. As long as you can do it in one liner, seems reasonable to me.
Hi! I'm not sure, that is bug, but by default
JacksonJsonProvider.class
not registrated in JerseyConfiguration module.I have situation:
Simple controller:
where ApplicationInfo is POJO binded as singleton with @singleton annotation.
I run in IDE, go to /version endpoint — all goes good.
I build package with maven, run it and get error
MessageBodyWriter not found for media type=application/json, type=class com.my.package.ApplicationInfo, genericType=class com.my.package.ApplicationInfo.
Other mime-types work fine.
I found solution. It's necessary to manual register JacksonJsonProvider.class in JerseyConfiguration:
Correct me if i'm wrong
PS: Thanks a lot for your lib. I have same troubles, you solution made my life easier :)
The text was updated successfully, but these errors were encountered: