Hi Colin,

One of the compromises Ring makes for efficiency is that the body of a
request is an InputStream, rather than a static string or byte array
pre-loaded into memory. Because it's a stream, it can potentially be
consumed by previous middleware.

For some reason you have both wrap-json-body and wrap-json-params in your
stacktrace:

    ring.middleware.json$wrap_json_body$fn__1031.invoke(json.clj:19)
  ring.middleware.json$wrap_json_params$fn__1035.invoke(json.clj:31)

Both middleware read from the body InputStream, so one of them is going to
fail when you try and read the body twice.

- James


On 4 November 2013 00:20, Colin Yates <colin.ya...@gmail.com> wrote:

> Hi all,
>
> I have developed a ring/compojure app which receives and servers JSON.
>  All is well in 'lein ring server' but as soon as I do 'lein ring uberwar'
> and deploy it to tomcat 6 or 7 it fails.  To be explicit, the app deploys
> and I can view the static resources, but as soon as I issue a JSON POST I
> get the following error:
>
> [code]
> java.io.IOException: Stream closed
> org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:325)
>
> org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193)
>  sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
> sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
>  sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
> java.io.InputStreamReader.read(InputStreamReader.java:184)
>  java.io.BufferedReader.fill(BufferedReader.java:154)
> java.io.BufferedReader.read(BufferedReader.java:175)
> clojure.core$slurp.doInvoke(core.clj:6279)
>  clojure.lang.RestFn.invoke(RestFn.java:410)
> ring.middleware.json$read_json.doInvoke(json.clj:12)
> clojure.lang.RestFn.invoke(RestFn.java:423)
>  ring.middleware.json$wrap_json_body$fn__1031.invoke(json.clj:19)
> ring.middleware.json$wrap_json_params$fn__1035.invoke(json.clj:31)
>  compojure.core$routing$fn__362.invoke(core.clj:107)
> clojure.core$some.invoke(core.clj:2443)
> compojure.core$routing.doInvoke(core.clj:107)
>  clojure.lang.RestFn.applyTo(RestFn.java:139)
> clojure.core$apply.invoke(core.clj:619)
> compojure.core$routes$fn__366.invoke(core.clj:112)
>  health.servlet$_service$fn__1016.invoke(servlet.clj:1)
> ring.util.servlet$make_service_method$fn__50.invoke(servlet.clj:126)
>  health.servlet$_service.invoke(servlet.clj:1)
> health.servlet.service(Unknown Source)
> [/code]
>
> Any help?
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to