views:

34

answers:

1

Basically, I have some models which all use JAXB. However, I have some highly custom functionality to convert to JSON and back so I want to write my own MessageBodyReader/Writer to do the job for me.

Right now, the writing portion is done: if i return one of my models from a REST resource, it goes through my writer. But when I try and accept a model as a FormParam, it doesnt use my MessageBodyReader and instead attempts to unmarshal it using JAXB (which fails).

So how I can tell Jersey to use my Reader instead?

public TestModel testProvider(@FormParam("model") TestModel input){ //doesnt work
  return new TestModel(); //this part works!
}
A: 

Since your writer works, but your reader does not, I'm guessing you have just missed something in your configuration. Some things to check:

  • Do you have the @Provider annotation on your reader?
  • Did you correctly implement the isReadable method on your reader?
  • Do you have the appropriate @Consumes annotation on the reader, does its media type match the media type specified on your service method?
Blaise Doughan