Jersey web services - java

I am trying to set up a simple Java web application using jersey for web services. However I have de following problem.
The tomcat server can’t find the resource http://localhost:8081/OnlineShop/rest/books/list but it can find my simple servlet http://localhost:8081/OnlineShop/index
I have the following web.xml
In the other hand I noticed that com.sun.jersey.spi.container.servlet.ServletContainer is present in my project because I added the dependency using maven however jersey.config.server.provider.packages is not present. Maybe that is the problem but I don’t know the exact dependency which I have to add.
My BookRest.java has the following code and is on the com.shop.rest package.
Finally my pom.xml has the following dependencies.
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib-ext-spring</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

Please, please get rid of this whole project. You're obviously a beginner and seem to be just putting random configurations and dependencies together, maybe from different tutorials. Your dependencies are incompatible and your web.xml configuration is wrong. Like i said, scrap the whole project and start from scratch. If you are just beginning, you should use one of the startup apps.
You're in Netbeans, so just do the following
File → New Project
Maven → Project from Archetype
Search jersey-quickstart-webapp
Select the one with the Group ID org.glassfish.jersey.archetypes
The latest version should be displayed.
Should be self explanitory from there
You will that the only dependency added is
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
And the web.xml will look something like
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.stackoverflow.jersey</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
This will get you a simple app up and running. You will see a dependency that you need to un-comment for JSON support. Un-comment it. Or better yet, un-comment it, then change jersey-media-moxy to jersey-media-json-jackson. Jackson is IMO a better JSON library.
Also keep the Jersey Documentation handy for some good reading and reference material for working with Jersey

Related

Use Provided jax-rs 2.0 and Jersey 2.1x in Weblogic 12c (12.2.1.3)

I need to implement a rest service call in my WEB application. According to Oracle, Weblogic is supported and does not need to register (deploy) jax-rs, so I would like to use these Server libraries. I made a simple class by calling a service (get). I configured the dependencies in the project and deployed it on Weblogic. However, when deploying, the following error appears: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider to org.glassfish.jersey.server.spi.ComponentProvider
Note: It worked using this link below (deploying the jar on the server) But I want to use the native libraries on Weblogic. Could someone help me please?
https://docs.oracle.com/middleware/1213/wls/RESTF/use-jersey20-ri.htm#RESTF297
Code example (Java)
String host = "https://swapi.dev/api/people/2/";
Client client = ClientBuilder.newBuilder().build();
WebTarget webTarget = client.target(host);
Builder builder = webTarget.request(MediaType.APPLICATION_JSON);
String result = builder.get(String.class);
pom.xml
<properties>
<primefaces.version>3.5.RC1</primefaces.version>
<jersey.version>2.21.1</jersey.version>
<jaxrs.version>2.0</jaxrs.version>
</properties>
<!-- JAX-RS -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jaxrs.version}</version>
<scope>provided</scope>
</dependency>
<!-- Jersey 2.21.1 -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
weblogic.xml
<wls:weblogic-version>12.2.1.3</wls:weblogic-version>
<wls:context-root>RecebimentoMercadoriaWEB</wls:context-root>
<wls:library-ref>
<wls:library-name>jsf</wls:library-name>
</wls:library-ref>
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
<wls:session-descriptor>
<wls:cookie-name>CookieRecebimentoMercadoria</wls:cookie-name>
</wls:session-descriptor>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>javax.faces.*</wls:package-name>
<wls:package-name>com.sun.faces.*</wls:package-name>
<wls:package-name>com.sun.facelets.*</wls:package-name>
<wls:package-name>com.bea.faces.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>javax.faces.*</wls:resource-name>
<wls:resource-name>com.sun.faces.*</wls:resource-name>
<wls:resource-name>com.sun.facelets.*</wls:resource-name>
<wls:resource-name>com.bea.faces.*</wls:resource-name>
<wls:resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</wls:resource-name>
<wls:resource-name>META-INF/services/com.sun.faces.spi.FacesConfigResourceProvider</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
On Weblogic 12.2.1.3 yo do not need to execute the procedure described by the link you have pointed, I mean the link below .
https://docs.oracle.com/middleware/1213/wls/RESTF/use-jersey20-ri.htm#RESTF297
This is because that link belongs to Oracle Weblogic 12.1.3 and there are several differences between Weblogic 12.1.3.0 and Weblogic 12.2.1.3.
Furthermore, this document for Oracle Weblogic 12.2.1.3 states.
Note:
Jersey 2.x (JAX-RS 2.0 RI) support is provided by default in this
release of WebLogic Server. Registration as a shared library is no
longer required.
This means, when it comes to Weblogic 12.2.1.3 Jersey libraries are in place and ready to be used. Thus, your application should be able to use them.
However, I think server libraries are getting troubles with the libraries you are using within your pom.xml file.
Furthermore Oracle Weblogic 12.2.1.3 provides jersey 2.22.4
I have also used wls-cat in one of my servers to know, which library is loading the class org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider and I have found the library in $ORACLE_HOME/oracle_common/modules/org.glassfish.jersey.ext.cdi.jersey-cdi1x.jar, which means it is loaded by Weblogic as is stated on above documentation.
Furthermore, after running wls-cat I can see this:
org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider implements org.glassfish.jersey.server.spi.ComponentProvider
Thus, cast should not be an issue, which means there is a class loading problem that most probably is caused by libraries included in your application.
You can see the results of wls-cat executed on my server on below picture
You can use wls-cat to see which file (a JAR library) is loading the conflicting class. In below post you will find information about how to use wls-cat to analyse class loading problems.
https://blog.sysco.no/class/loader/AnalysingClassLoadingConflicts/
The libraries were really conflicting. I removed these dependencies from pom.xml and it worked. Thanks for the tip.
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>

make wadl file resteasy without maven

i am trying to make Wadl file for rest services in my application , i am using resteasy , all tutorials and examples is to make it with maven & jersy
i dont use maven i use eclipse Wildfly and Resteasy , is there is any explanation how to make this .
thank you.
As of Resteasy 3.0.14-Final this should be possible:
https://issues.jboss.org/browse/RESTEASY-166
https://docs.jboss.org/resteasy/docs/3.1.0.Final/userguide/html/WADL.html
Add this to your web.xml:
<servlet>
<servlet-name>RESTEasy WADL</servlet-name>
<servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RESTEasy WADL</servlet-name>
<url-pattern>/application.xml</url-pattern>
</servlet-mapping>
I tried this on WildFly 10.1.0 and I had to include an extra library:
Maven artifact: https://javalibs.com/artifact/org.jboss.resteasy/resteasy-wadl
Add the following to your pom.xml:
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-wadl -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-wadl</artifactId>
<version>3.0.14.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</exclusion>
</exclusions>
</dependency>
Next re-publish and access the WADL at [context-root]/application.xml

Vaadin 7.1.1: Failed to load the widgetset

I have problem to run latest Vaadin 7.1.1 applications. It's mostly because I cannot find documentation for that version. Maven archetype creates old style app extending Root. Root is gone, so I'm trying to extend UI, like they do in Book of Vaadin.
web.xml:
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>
com.vaadin.server.VaadinServlet
</servlet-class>
<init-param>
<param-name>UI</param-name>
<param-value>cz.simplecoin.simplegui.MainScreen</param-value>
</init-param>
</servlet>
and MainScreen simply:
public class MainScreen extends UI {
Project compiles (with maven) correctly. When I debug I see init method of MainScreen called correctly, but I see only blank screen (bootstrap JavavScript is there) with the alert:
Error:
Failed to load the widgetset:./VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/com.vaadin.DefaultWidgetSet.nocache.js?1393503103223
I want to start with Default widgetset. I'm almost sure that it's somehow problem in maven build/dependency. I have no Idea what libraries to use: I tried both variants (commented)
pom.xml:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!--
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-theme-compiler</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>vaadin-charts</artifactId>
<version>1.0.0</version>
</dependency>
-->
I may try to use own widgetset,to see if that solves the issue.
Well I got it finally up by adapting latest demo app pom.xml directly from git. Missing widgetset is in
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
Than I noticed that if you run tomcat as an adapter in eclipse and you deploy your project into it, then sometimes after you have build your project, the target folder is not in sync with eclipse and you have to press F5 on it. After this action the widgetset could be loaded.

Different behaviour using mvn jetty:run or jetty standalone

I have a project with multiple modules.
Two of them generate war files.
One war file is a REST application and provides a couple of resources.
The Other war file is a Angular JS web application (static content only) to talk to the REST backend.
For demo purposes I'd like to deploy both war-files very easily with mvn jetty:run
For development purposes I'd like to deploy them from my IDE (e.g. Eclipse Servers View).
When I do the deployment on a single Jetty Server (v9.0.7.v20131107) manually by starting the server and copiing the war-files to the deployment folder everything comes up.
When starting the jetty by mvn jetty:run both war files get deployed, but somehow the REST Resources do not get deployed.
I am using Jersey 2. When deploying manually I get a log message like
Nov 14, 2013 10:44:37 PM org.glassfish.jersey.server.ApplicationHandler initialize
INFO: Initiating Jersey application, version Jersey: 2.4 2013-10-24 18:25:49...
However this message is not been shown when starting with mvn jetty:run. Therefore I assume that Jersey does not kick in.
For Dependency-Injection I use spring.
This is the parent pom in /pom.xml with the jetty-maven-plugin configuration
<project ...>
...
<build>
<plugins>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.7.v20131107</version>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>module1/target/module1-${project-version}.war</war>
<contextPath>/module1</contextPath>
</contextHandler>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>module2/target/module2-${project.version}.war</war>
<contextPath>/module2/contextPath>
</contextHandler>
</contextHandlers>
</configuration>
</plugins>
</build>
...
</project>
This is the pom for module1 (the REST module)
<parent>
...
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module1</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<springVersion>3.1.4.RELEASE</springversion>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.4</version>
</dependency>
<!-- Dependencies to internal modules -->
...
<!-- Depenencies to internal modules END -->
</dependencies>
</project>
This is the web.xml for module1
<web-app ...
version="3.0">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
This is the applicationContext.xml for module1
<beans ...>
<context:annotation-config/>
<context:component-scan base-package="com.stackoverflow.zip"/>
<aop:aspectj-autoproxy/>
</beans>
This is the Module1Application class for module1
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;
#ApplicationPath("/rest")
public class Module1Application extends Application {
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Resource1.class);
classes.add(Resource2.class);
classes.add(MultiPartFeature.class);
return classes;
}
}
This is the pom for module2 (the AngularJS app)
Very light :)
<project ...>
<parent>
...
</parent>
...
<modelVersion>4.0.0</modelVersion>
<artifactId>module2</artifactId>
<packaging>war</packaging>
</project>
Do you have any idea why the Jersey Application does not get instantiated while running with mvn jetty:run but when running it manually?
I appreciate any input on this topic.
Kind regards
- zip
Your javax.servlet version is 2.5 in pom.xml, but 3.0 in web.xml. Try upgrading it to 3.0 in pom.xml. Is it possible that the IDE provides a servlet 3.0 for you?
Also, since Jetty provides a javax.servlet container, try putting the Servlet Api into provided scope in pom.xml. Something like this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<!-- http://stackoverflow.com/a/15601606 http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope -->
<!-- This allows us to compile the application locally but does not include the jar in the package step -->
<scope>provided</scope>
</dependency>
It's possible that you want to add a <load-on-startup>1</load-on-startup> element to your web.xml. Check out http://tutorials.jenkov.com/java-servlets/web-xml.html#load-on-startup
That's whole tutorial is pretty good.
Disclaimer: I'm not familiar with what the Spring dependencies are doing to help your application bootstrap itself. You can always try removing dependencies on a separate branch, and adding them back in as you get things running
I haven't had a chance to play with Jersey 2.x so far, but from what I see in your web.xml, it doesn't look like you have Jersey setup correctly.
In a non-Spring application, you would have something like the following:
<web-app ...>
...
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.your.foo.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
...
</web-app>
In a Spring-based one, you would use:
<web-app ...>
...
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.your.foo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
...
</web-app>
Furthermore, check that you have these Maven dependencies:
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

Setting up Jax-rs 2.2 with Jetty

I'm trying to set up some REST services on Jetty using Jersey JAXRS. I can't get json data through to my REST service class though. My ajax requests keep getting the "Unsupported Media Type" error and status. I get this regardless of what #Produces and #Consumes annotations I add to my methods though they should both be MediaType.APPLICATION_JSON.
I can't find decent documentation on Jersey and the loads of questions, blogs, and other resources all seem to be out of date. Looks like Jersey has undergone a lot of changes recently and I'm at a loss as to where I should be looking. I set up the following based on the jersey webapp archetype:
web.xml:
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.my.package.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Code snippet:
#Path("/users")
public class UserService {
// Plain text works!
#GET
#Consumes(MediaType.TEXT_PLAIN)
public String list(){
return "Got it!";
}
// JSON doesn't work! >:(
#POST
#Consumes(MediaType.APPLICATION_JSON)
#Produces(MediaType.APPLICATION_JSON)
public User create(User user) {
Mocks.USERS.add(user);
return user;
}
My parent pom manages these dependencies ahd the second of these two is a dependency in my jax-rs project pom.
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.2</version>
</dependency>
Do I need something to add support for JSON?
Have you read a chapter dedicated to JSON in the Users Guide? The easiest way would be adding a dependency on MOXy and JSON support would work out-of-the-box (you don't need to explicitly register features the modules provides to make it work as opposed to other JSON modules in Jersey):
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.2</version>
</dependency>
Anyways Jersey provides more modules that would help you with handling JSON media type:
MOXy (examples: json-moxy, bean-validation-webapp)
Jackson (example: json-jackson)
Java API for JSON Processing (JSON-P) (example: json-processing-webapp)
Jettison (example: json-jettison)
Seems Drew was on the right track in his comment. But the answer (for Jersey 2.2 + Jackson at least) was a more up-to-date provider
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.2.3</version>
</dependency>
Using this required no configuration. Use this with the two dependencies in the original questions and you're in business.
JSON start working for me just with 2 dependencies:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.2.3</version>
</dependency>

Categories