RESTful Webservices are an essential and convenient part in current web applications when Information should be exchanged. Additionally the main exchange formats in current webservices are either JSON or XML.
So when we want to implement the serverside of a web application using Java and especially REST services, we might end up serializing and deserializing objects to and from XML and JSON. Honestly not a very desirable task. But fortunately there is the Jersey project which can help us in this task.
Using Jersey, we can use an XML free configuration and fully transparent (de-)serialization of POJOs. Yet setting up the configuration isn’t that simple if you are not too familiar with all the configuration. Actually there are quite a lot of hints yet very rare extensive examples with a aworking (xml free!) configuration.
Actually the configuration is very simple – as soon as you got it working. As I ran into this issue several times now and always got stuck on another minor detail, I finally set up a sample project with a (hopefully) minimum example. This example can currently be found at GitHub in the JEE-Base project.
As we see:
- no XML
- just annotations
- no explicit (de-)serialization
- If you are facing the same issues, just visit or clone the JEE-Base project.