I have been working with the restfull webservices provide by Jersey in combination with the maven jetty plugin at my previous job. But now for a personal project i am starting from scratch by myself and i cant seem to get even the basic version going. I have tried to follow a few tutorial but they are either old or off topic.
The most recent example i tried was: jersey 2 + spring 4 + jetty-maven-plugin
So the below configs make the plug in run but no matter which url i try it gives me 404's
pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<jetty.version>9.3.11.v20160721</jetty.version>
<jersey.version>2.23.1</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
</plugin>
</plugins>
</build>
</project>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>test</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.foo.bar</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>
resourceConfiguration.java
package com.foo.bar;
import org.glassfish.jersey.server.ResourceConfig;
public class ResourceConfiguration extends ResourceConfig {
public ResourceConfiguration() {
register(entrypoint.class);
}
}
and my service class
package com.foo.bar;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
public class entrypoint {
@GET
@Path("/test")
@Produces(MediaType.TEXT_PLAIN)
public String test() {
return "it works";
}
@GET
@Path("/")
@Produces(MediaType.TEXT_HTML)
public String test2() {
return "it works";
}
}
Nothing fancy right i feel like this should work out of the box. The Jetty server starts but like i said i get jetty 404 pages at every url permutation i try.
Thanks in advance for any and all input.