title: OPTIONS request for restful cross-domain using CORS
body: <p>On client side I'm using Ajax.post (jquery 1.5) with json. On server side I'm using rest resteasy-jaxrs-2.0.1.GA. I found somewhere that i should add couple of headers to server response and I've done with following filter:</p>
  
  <pre><code>public void doFilter(   ServletRequest req,
                          ServletResponse res,
                          FilterChain filterChain)
      throws IOException, ServletException {
  
      MyServletRequestWrapper httpReq    = new MyServletRequestWrapper((HttpServletRequest)req);
      HttpServletResponse    httpRes   = (HttpServletResponse)res;
  
      HttpSession session = httpReq.getSession();
  
  
      httpRes.addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*");
      httpRes.addHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
  
     if (((HttpServletRequest) req).getMethod().equals("OPTIONS")){
          httpRes.addHeader(ACCESS_CONTROL_ALLOW_METHODS, "GET, POST, OPTIONS, PUT, DELETE");
          httpRes.addHeader(ACCESS_CONTROL_ALLOW_HEADERS, "content-type, x-requested-with, x-requested-by");
     }
  
    filterChain.doFilter(httpReq, httpRes);
  
  }
  </code></pre>
  
  <p>It works fine cause to every single GET response above headers are added. Problem appears when I want to use POST request. When I use Ajax.post, at first server gets OPTIONS request and I've got following error:</p>
  
  <p><code>
  Failed executing OPTIONS [REST_PATH]
  org.jboss.resteasy.spi.DefaultOptionsMethodException: No resource method found for options, return OK with Allow header </code></p>
  
  <p>To solve above error I was trying to add method invoke with the same path as POST ([REST_PATH]) but with @OPTION annotation. In that case javac told me that symbol :class OPTIONS could not be found, even there is a OPTION.class in attached jaxrs library.</p>
  
  <p>Any ideas to fix it? I would be very grateful for any clues.</p>