3

I do RESTful application in Jersey (deployed on WildFly 8.1.0.Final) but I have a problem with testing methods @DELETE. All other (GET, POST, PUT) work as expected. However, when calling @DELETE I receive the following error message

Cross-Origin Resource Sharing (CORS) Filter: Unsupported HTTP method: DELETE 

I test RESTful interface via a plugin in Google Chrome: Advanced REST Client. How can I fix it?

Resource class: I deleted other methods for better clarity.

@Path(value = "destination") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public class DestinationResource { public DestinationResource() {} @DELETE @Path(value = "/{id}") public Response deleteDestination(@PathParam("id") Long id) { //Doing something return Response.status(Response.Status.OK).build(); } 

}

EDIT: I added CORS.filter but still nopt working. Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?> <!-- This web.xml file is not required when using Servlet 3.0 container, see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html#d4e194 --> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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 Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> <context-param> <param-name>resteasy.scan</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.providers</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.resources</param-name> <param-value>false</param-value> </context-param> <filter> <!-- The CORS filter with parameters --> <filter-name>CORS</filter-name> <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class> <!-- Note: All parameters are options, if omitted the CORS Filter will fall back to the respective default values. --> <init-param> <param-name>cors.allowGenericHttpRequests</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>cors.allowOrigin</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.allowSubdomains</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>cors.supportedMethods</param-name> <param-value>GET, HEAD, POST, PUT, OPTIONS</param-value> </init-param> <init-param> <param-name>cors.supportedHeaders</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.exposedHeaders</param-name> <param-value>X-Count-records</param-value> </init-param> <init-param> <param-name>cors.supportsCredentials</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>cors.maxAge</param-name> <param-value>3600</param-value> </init-param> </filter> <filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

2
  • Show us how the CORS filter is configured. It is causing this error, not your JAX-RS class. Commented Oct 26, 2014 at 7:34
  • Maybe there is problem because I didnt configured CORS filter at all. Commented Oct 26, 2014 at 8:06

1 Answer 1

5
<init-param> <param-name>cors.supportedMethods</param-name> <param-value>GET, HEAD, POST, PUT, OPTIONS</param-value> </init-param> 

Do you see DELETE listed there? I don't.

Sign up to request clarification or add additional context in comments.

1 Comment

I don´t see it too. Stupid mistake that cost me 5 hours of my life. Thanks for help now it is working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.