« Return to Thread: RESTClient get NPE when response status = 201

Re: RE[groovy-user] STClient get NPE when response status = 201

by Tom Nichols :: Rate this Message:

Reply to Author | View in Thread

It sounds the same as this bug report:
http://jira.codehaus.org/browse/GMOD-95
If you're willing to build from source, try the RC-1 tag with the
replacement HTTPBuilder.java that's attached to the bug report.  This
is something difficult for me to test myself, as I don't know of a
public web service that emulates the behavior.

But the NPE is thrown from w/in a catch block, which means it's
masking some other error that's occurring during parsing.  If you can
try out that patch, please let me know your result.

On Sat, Jun 27, 2009 at 12:42 AM, mikemil<mikemil@...> wrote:

>
> I am trying to use the RESTClient class to do a post to a RESTful web
> service.   I am getting an NPE at HTTPBuilder.java:461 - after turning on
> the debugging log (see below) it appears that my post is working and the
> resource is created, but I still get the NPE.   I do see the status code =
> 201 and no XML is returned.  Am I doing something wrong or is this a bug???
>
>
>
> 2009-06-26 23:23:01,859 [Thread-8] DEBUG http.RESTClient  - POST
> http://localhost:8080/simple/rest-services/customers/
> 2009-06-26 23:23:02,250 [Thread-8] DEBUG conn.SingleClientConnManager  - Get
> connection for route HttpRoute[{}->http://localhost:8080]
> 2009-06-26 23:23:02,312 [Thread-8] DEBUG client.ClientParamsStack  -
> 'http.protocol.version': HTTP/1.1
> 2009-06-26 23:23:02,312 [Thread-8] DEBUG client.ClientParamsStack  -
> 'http.useragent': Apache-HttpClient/4.0-beta2 (java 1.5)
> 2009-06-26 23:23:02,312 [Thread-8] DEBUG client.ClientParamsStack  -
> 'http.protocol.expect-continue': true
> 2009-06-26 23:23:02,312 [Thread-8] DEBUG protocol.RequestAddCookies  -
> CookieSpec selected: best-match
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG client.DefaultRequestDirector  -
> Attempt 1 to execute request
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG http.wire  - >> "POST
> /simple/rest-services/customers/ HTTP/1.1[EOL]"
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG http.wire  - >> "Accept: */*[EOL]"
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG http.wire  - >> "Content-Length:
> 196[EOL]"
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG http.wire  - >> "Content-Type:
> application/xml[EOL]"
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG http.wire  - >> "Host:
> localhost:8080[EOL]"
> 2009-06-26 23:23:02,343 [Thread-8] DEBUG http.wire  - >> "Connection:
> Keep-Alive[EOL]"
> 2009-06-26 23:23:02,375 [Thread-8] DEBUG http.wire  - >> "User-Agent:
> Apache-HttpClient/4.0-beta2 (java 1.5)[EOL]"
> 2009-06-26 23:23:02,390 [Thread-8] DEBUG http.wire  - >> "Expect:
> 100-Continue[EOL]"
> 2009-06-26 23:23:02,421 [Thread-8] DEBUG http.wire  - >> "Accept-Encoding:
> gzip,deflate[EOL]"
> 2009-06-26 23:23:02,453 [Thread-8] DEBUG http.wire  - >> "[EOL]"
> 2009-06-26 23:23:02,468 [Thread-8] DEBUG http.headers  - >> POST
> /simple/rest-services/customers/ HTTP/1.1
> 2009-06-26 23:23:02,500 [Thread-8] DEBUG http.headers  - >> Accept: */*
> 2009-06-26 23:23:02,515 [Thread-8] DEBUG http.headers  - >> Content-Length:
> 196
> 2009-06-26 23:23:02,546 [Thread-8] DEBUG http.headers  - >> Content-Type:
> application/xml
> 2009-06-26 23:23:02,578 [Thread-8] DEBUG http.headers  - >> Host:
> localhost:8080
> 2009-06-26 23:23:02,593 [Thread-8] DEBUG http.headers  - >> Connection:
> Keep-Alive
> 2009-06-26 23:23:02,625 [Thread-8] DEBUG http.headers  - >> User-Agent:
> Apache-HttpClient/4.0-beta2 (java 1.5)
> 2009-06-26 23:23:02,656 [Thread-8] DEBUG http.headers  - >> Expect:
> 100-Continue
> 2009-06-26 23:23:02,671 [Thread-8] DEBUG http.headers  - >> Accept-Encoding:
> gzip,deflate
> 2009-06-26 23:23:02,703 [Thread-8] DEBUG http.wire  - << "HTTP/1.1 100
> Continue[EOL]"
> 2009-06-26 23:23:02,734 [Thread-8] DEBUG http.headers  - << HTTP/1.1 100
> Continue
> 2009-06-26 23:23:02,765 [Thread-8] DEBUG http.wire  - >>
> "<customer><firstname>Mike</firstname><lastname>Miller</lastname><street>2713
> River
>  Bend Trail</street><city>Flower
> Mound</city><state>Texas</state><zip>75022</zip><country>USA</country></customer>"
> 2009-06-26 23:23:02,812 [Thread-8] DEBUG http.wire  - << "HTTP/1.1 201
> Created[EOL]"
> 2009-06-26 23:23:02,843 [Thread-8] DEBUG http.wire  - << "Server:
> Apache-Coyote/1.1[EOL]"
> 2009-06-26 23:23:02,859 [Thread-8] DEBUG http.wire  - << "Location:
> http://localhost:8080/simple/rest-services/customers/7[EOL]"
> 2009-06-26 23:23:02,890 [Thread-8] DEBUG http.wire  - << "Content-Length:
> 0[EOL]"
> 2009-06-26 23:23:02,906 [Thread-8] DEBUG http.wire  - << "Date: Sat, 27 Jun
> 2009 04:23:02 GMT[EOL]"
> 2009-06-26 23:23:02,937 [Thread-8] DEBUG http.headers  - << HTTP/1.1 201
> Created
> 2009-06-26 23:23:02,968 [Thread-8] DEBUG http.headers  - << Server:
> Apache-Coyote/1.1
> 2009-06-26 23:23:02,984 [Thread-8] DEBUG http.headers  - << Location:
> http://localhost:8080/simple/rest-services/customers/7
> 2009-06-26 23:23:03,015 [Thread-8] DEBUG http.headers  - << Content-Length:
> 0
> 2009-06-26 23:23:03,031 [Thread-8] DEBUG http.headers  - << Date: Sat, 27
> Jun 2009 04:23:02 GMT
> 2009-06-26 23:23:03,078 [Thread-8] DEBUG client.DefaultRequestDirector  -
> Connection can be kept alive for -1 ms
> 2009-06-26 23:23:03,093 [Thread-8] DEBUG http.RESTClient  - Response code:
> 201; found handler: org.codehaus.groovy.runtime.MethodClosure@13c
> 2797
> 2009-06-26 23:23:03,156 [Thread-8] DEBUG conn.SingleClientConnManager  -
> Releasing connection org.apache.http.impl.conn.SingleClientConnMana
> ger$ConnAdapter@4b5011
> 2009-06-26 23:23:03,281 [Finalizer] DEBUG conn.DefaultClientConnection  -
> Connection shut down
> --
> View this message in context: http://www.nabble.com/RESTClient-get-NPE-when-response-status-%3D-201-tp24230427p24230427.html
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: RESTClient get NPE when response status = 201