I'm facing Jersey 2.7. This is my service:
package edu.srv.rest;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Application;
@Path("/algebra")
public class Algebra extends Application {
@GET
@POST
@Path("/sum")
public int sum(@QueryParam("a") int a, @QueryParam("b") int b) {
return a + b;
}
}
this is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>RS1</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>edu.srv.rest.Algebra</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RS1</servlet-name>
<url-pattern>/algebra/*</url-pattern>
</servlet-mapping>
</web-app>
and this is my project structure:
when I try to deploy (tomcat 6, tomcat 7, tomcat 8) this service as war I got this exception:
java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.model.ContractProvider$Builder
what am I missing?