Reputation: 33
I've seen some posts about this topic, but they didn't help me to find the issue. I'm trying to get Jersey 2.22 going with GAE SDK 1.9.25, but I keep getting 404.
The console says:
Nov 05, 2015 4:02:57 PM org.glassfish.jersey.server.ServerRuntime$Responder mapException
FINE: WebApplicationException (WAE) with no entity thrown and no ExceptionMappers have been found for this WAE. Response with status 404 is directly generated from the WAE.
javax.ws.rs.NotFoundException: HTTP 404 Not Found
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:323)
My class looks like this:
package com.jt.jjbackend;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class JJServlet {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayHello(){
return "Hello";
}
}
and here is my web.xml:
<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.jt.jjbackend</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I used http://localhost:8888/rest/hello which I think is correct, as I get a different error in the console when I enter a bogus link. I also added a regular test servlet which worked just fine.
What am I doing wrong or what am overlooking? Your help is much appreciated.
Stephan
Upvotes: 1
Views: 1265
Reputation: 209132
Change com.sun.jersey.config.property.packages
to jersey.config.server.provider.packages
in your web.xml. The former is for Jersey 1.x, while the latter is for 2.x. They mean the same thing in their respective versions, but they are not interchangeable.
Upvotes: 1