I am new to RESTful Services.
I am trying to deploy a simplest REST service using jersey, and JAX-RS, but i am getting this error,
HTTP ERROR: 404 NOT_FOUND RequestURI=/hosting/demo/example Powered by Jetty://
Where i think i have done everything right, below is the code i am using for it.
POM.XML (only pasting the part related to jersey)
<dependency>
<!-- the implementation of JAX-RS -->
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
WEB.XML
<servlet>
<servlet-name>jersey</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>mop.core.service.restservices</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/demo</url-pattern>
</servlet-mapping>
My Class having @GET
package mop.core.service.restservices;
import javax.swing.JOptionPane;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/example")
public class PricePointRestService {
@GET
@Produces("text/plain")
public String getPricePoint(){
JOptionPane.showMessageDialog(null, "GET CALLED");
return "hello";
}
@POST
@Produces("application/xml")
@Consumes({"application/x-www-form-urlencoded", "multipart/form-data"})
public String doPost(@FormParam("xml") String xml) {
return "<xml></xml>";
}
}
The url i hit is: http://localhost/hosting/demo/example
Please help, its very urgent, thanks in advance