I am attempting to recreate the most excellent vogella tutorial for create REST with java, JAX-RS and Jersey.
I\'m using eclipse Kepler with Java-EE perspective, to
Have you written any custom MessageBodyWriter for your marshalling from Java to JSON. If yes then you need to have the @Produces annotation with 'application/json' in the provider implementation. For more details refer http://h2labz.blogspot.in/2014/12/marshalling-java-to-json-in-jax-rs.html
My understanding is that the jaxrs-ri 2.13 bundle includes everything required including dependencies to let me do this - and that I don't need to add any kind of JSON provider.
That's actually incorrect. As stated at the Jersey User Guide 8.1. JSON
Jersey JSON support comes as a set of extension modules where each of these modules contains an implementation of a Feature that needs to be registered into your Configurable instance (client/server). There are multiple frameworks that provide support for JSON processing and/or JSON-to-Java binding. The modules listed below provide support for JSON representations by integrating the individual JSON frameworks into Jersey. At present, Jersey integrates with the following modules to provide JSON support:
MOXy - JSON binding support via MOXy is a default and preferred way of supporting JSON binding in your Jersey applications since Jersey 2.0. When JSON MOXy module is on the class-path, Jersey will automatically discover the module and seamlessly enable JSON binding support via MOXy in your applications. (See Section 4.3, “Auto-Discoverable Features”.)
Among a few others
So the main Jersey download doesn't come with these extra modules. We need to obtain them separately. That being said, the easiest way to get the required jersey-media-moxy is through Maven.
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.13</version>
</dependency>
If you're not using Maven (which looking through the tutorial, it doesn't), you're going to have to do some searching for the dependencies. The jersey-media-moxy
artifact has 16 dependencies, but Fortunately, most are contained within the Jersey distribution. So after filtering out what was already included in the Jersey distro, these are the remaining jars you will have to find on your own (I just created a User Library to test out)
Adding these dependencies will get the example up and running. Tested and works as expected after adding these.
Now you have Eclipse, which I assume came with the Maven (m2e) plugin. So maybe the easiest way to get these dependencies is to create a new Maven project, and add the dependency shown above. After you build the project, maven should download all the extra dependencies into your local Maven Repo. Just grab them from there for your main project.
Other Resources/Notes
If your are using Jersey-2
Web.xml Configuration
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servletclass>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.oracle.restful</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
List of Libraries required
Run project it will work. Also check your JAXB classed because it will internally use xml annotation to convert pojo object to JAXB