Yes, indeed, thanks,

and as to why HTTPUrlConnection keeps blocking HTTP verbs even with the latest versions - you'd need to ask at Java forums. People use new verbs like PATCH or WebDav verbs so it is strange that such verbs are still not supported in JDK - at least they could've introduced a property which, if enabled, would let HTTPUrlConnection accept any HTTP verb.

@Patch annotation has been added to save some users from typing their own JAX-RS HttpMethod extensions - which is what JAX-RS recommends, if JAX-RS API itself has no the annotation for a given HTTP method then can support such a method with a JAX-RS HttpMethod-based annotation

Cheers, Sergey
On 20/08/15 13:34, Jose María Zaragoza wrote:
2015-08-20 11:46 GMT+02:00 PatrikStas <patrik.s...@gmail.com>:
Hi everyone !

I've been trying to get the @PATCH method get working for a while now but
with not further success.
I've noticed it haven't been present in CXF 3.0.2, but been added to CXF
3.1.2 into the package package org.apache.cxf.jaxrs.ext; ( it's missing in
documnetation tho )

When I try to use PATCH method to call my service, I get
*
Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH
         at 
java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:428)*

The setRequestMethod is looking for methodn name in statically defined list
of methods, defined as
*
     private static final String[] methods = {
         "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"
     };*

And since it doesn't find PATCH, it throws
*
         throw new ProtocolException("Invalid HTTP method: " + method);*

Browsing forums and mailing lists, I found these posts here :

http://comments.gmane.org/gmane.comp.apache.cxf.user/25919

Saying I can use async transport and then the PATCH should work

*         String address = "http://localhost:"; + PORT +
"/bookstore/retrieve";
          WebClient wc = WebClient.create(address);

WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit",
true);
          Book book = wc.invoke("RETRIEVE", null, Book.class);*


However, even if I try to call my service like this, it's still failing.

I think that you need to include cxf-rt-transports-http-hc

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-hc</artifactId>
<version>${cxf.version}</version>
</dependency>


Moreover even if this would work, I find it a bit hacky. Why is PATCH not
supported, if it's been added to CXF ?

I have other services working properly, the only service which are throwing
this exception are the ones annotated with @PATCH.

What is the problem ?

Thanks a lot in advance for any tips !
Patrik










--
View this message in context: 
http://cxf.547215.n5.nabble.com/PATCH-Method-is-failing-tp5760309.html
Sent from the cxf-user mailing list archive at Nabble.com.


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Reply via email to