I'm working on my first RESTful Api with Jersey 2.x
and tomcat 8
but when I try to acceed to my Resources I keep getting a 404 errors.
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://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID"
version="3.1">
<servlet>
<servlet-name>com.pj.api.application.Application</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>com.pj.api.application.Application</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
</web-app>
My Application class :
@ApplicationPath ("api")
public class Application extends ResourceConfig {
public Application () {
packages ("com.pj.api.resources");
}
}
My Resources class :
@Path ("value=/users")
public class UserResources extends ResourcesImpl {
private UserDao user = new UserDao ();
@Override
public List<Data> getList () {
return user.getList ();
}
@GET
@Path ("value=/test")
public String Test () {
return "{'a':'hey'}";
}
@Override
public Data get (String id) {
return user.get (id);
}
@Override
public void post (Data data) {
user.post (data);
}
@Override
public void put (Data data) {
user.put (data);
}
@Override
public void delete(Data data) {
user.delete (data);
}
}
When deploying the project on Tomcat, and acceeding to the Service through the URL : http://localhost:8080/PJ/api/users/test
it gives me a 404 error and Cannot cast org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer to javax.servlet.ServletContainerInitializer
p.s : I do NOT use Maven
What could be the problem here ? Thank you.