Complex JAX-RS

Working with JAX-RS to create a REST web service, I recently had the need to accept a List of a complex type as a parameter.  I was not able to find a complete example but I did read some Jersey documentation which I had not looked at in quite some time.  I read the Jersey Parameter Annotations section.

The issue I was running into was the lack of a constructor for the complex type I wanted to pass in a list as a parameter to a REST web service method.  The documentation made me realize that I did not have a constructor which accepted a single String parameter from which an instance could be properly created.

I also had some trouble with JSON marshalling/unmarshalling.  This may be a topic for another time but for now I solved it using the ObjectMapper from Jackson.

Ultimately I put a trivial demo app together which is available here.  The application was created using NetBeans 7.4 as a maven web app to run on Glassfish 4.0 for convenience.

I hope this is of help to someone.

Happy coding,
Carl
Post a Comment

Popular posts from this blog

ClassCastException: JAXB

JDeveloper installation on Mac OS X Mountain Lion

Android and JavaFX