I know there lots of answered questions to the same topic, however none of the answers seem to feet my problem. I'm trying to do a REST WS in Java. @GET methods work ok, but when I try to do anything else (using either RESTClient or Poster -both Firefox extensions) I get the following message:
Status Code: 405 Method Not Allowed
Allow: GET,OPTIONS,HEAD
Content-Length: 0
Date: Thu, 02 Jan 2014 18:17:07 GMT
Server: Apache-Coyote/1.1
Example of CRUD methods:
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/Update/{addNewData}")
public Response Update(
@PathParam("addNewData") JSONObject addNewData) {
String str = new JSONObject().toString();
return Response.status(200).entity(str).build();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/AddNew/{addNewData}")
public Response AddNew(
@PathParam("addNew") JSONObject addNew) {
String str = new JSONObject().toString();
return Response.status(200).entity(str).build();
}
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.TEXT_PLAIN)
@Path("/Delete/{profileId}")
public Response Delete(@PathParam("profileId") String profileId) {
String str = new JSONObject().toString();
return Response.status(200).entity(str).build();
}
In case it's needed, here's the 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_2_5.xsd" 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>RMGTrackerServices</display-name>
<servlet>
<servlet-name>Jersey REST Service</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>middlewireServices</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Using Apache 7.0.47. Thanks in advance.