org.apache.http.impl.cookie.BasicClientCookie not serializable???

Posted by Misha Koshelev on Stack Overflow See other posts from Stack Overflow or by Misha Koshelev
Published on 2010-06-09T19:17:40Z Indexed on 2010/06/09 19:22 UTC
Read the original article Hit count: 297

Filed under:
|
|

Dear All:

I am quite confused... I am reading here and BasicClientCookie clearly implements Serializable per JavaDoc: http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/impl/cookie/BasicClientCookie.html

However, my simple Groovy script:

#!/usr/bin/env groovy
@Grapes(
    @Grab(group='org.apache.httpcomponents', module='httpclient', version='4.0.1')
)
import org.apache.http.impl.cookie.BasicClientCookie
import java.io.File

def cookie=new BasicClientCookie("name","value")
println cookie instanceof Serializable
def f=new File("/tmp/test")
f.withObjectOutputStream() { oos->
    oos.writeObject(cookie)
}

outputs:

false
Caught: java.io.NotSerializableException: org.apache.http.impl.cookie.BasicClientCookie
        at t$_run_closure1.doCall(t.groovy:12)
    at t.run(t.groovy:11)

I have checked and I have no other versions of HttpClient anywhere in classpath (if I take Grapes statement out it cannot find file).

Thank you! Misha Koshelev

© Stack Overflow or respective owner

Related posts about groovy

Related posts about httpclient