cognitect-labs / aws-api

AWS, data driven
Apache License 2.0
724 stars 100 forks source link

With pedestal and engine as jetty, put-object failing. Workaround: switch to tomcat. #235

Closed deafjava closed 1 year ago

deafjava commented 1 year ago

Dependencies

                 [com.cognitect.aws/api "0.8.656"]
                 [com.cognitect.aws/endpoints "1.1.12.415"]
                 [com.cognitect.aws/s3 "825.2.1250.0"]
                 ;; with
                 [io.pedestal/pedestal.route "0.5.8"]
                 [io.pedestal/pedestal.service "0.5.8"]
                 [io.pedestal/pedestal.jetty "0.5.8"]

Description

When using with jetty as engine of pedestal:

(defn create-server []
  (http/create-server
    {::http/routes routes
     ::http/type   :jetty
     ::http/port   3030}))

The call of invoke to put-object, e.g., {:op :PutObject, :request {:Bucket videos, :Key a-video.mov, :Body #object[java.io.ByteArrayInputStream 0x2f2783f7 java.io.ByteArrayInputStream@2f2583f7]}} fails:

{:cognitect.anomalies/category :cognitect.anomalies/fault, :cognitect.anomalies/message org/eclipse/jetty/io/CyclicTimeouts$Expirable, :cognitect.http-client/throwable #error {
 :cause org.eclipse.jetty.io.CyclicTimeouts$Expirable
 :via
 [{:type java.lang.NoClassDefFoundError
   :message org/eclipse/jetty/io/CyclicTimeouts$Expirable
   :at [org.eclipse.jetty.client.http.HttpClientTransportOverHTTP newHttpDestination HttpClientTransportOverHTTP.java 54]}
  {:type java.lang.ClassNotFoundException
   :message org.eclipse.jetty.io.CyclicTimeouts$Expirable
   :at [jdk.internal.loader.BuiltinClassLoader loadClass BuiltinClassLoader.java 581]}]
 :trace
 [[jdk.internal.loader.BuiltinClassLoader loadClass BuiltinClassLoader.java 581]
  [jdk.internal.loader.ClassLoaders$AppClassLoader loadClass ClassLoaders.java 178]
  [java.lang.ClassLoader loadClass ClassLoader.java 522]
  [org.eclipse.jetty.client.http.HttpClientTransportOverHTTP newHttpDestination HttpClientTransportOverHTTP.java 54]
  [org.eclipse.jetty.client.HttpClient lambda$resolveDestination$0 HttpClient.java 575]
  [java.util.concurrent.ConcurrentHashMap computeIfAbsent ConcurrentHashMap.java 1705]
  [org.eclipse.jetty.client.HttpClient resolveDestination HttpClient.java 573]
  [org.eclipse.jetty.client.HttpClient resolveDestination HttpClient.java 551]
  [org.eclipse.jetty.client.HttpClient send HttpClient.java 599]
  [org.eclipse.jetty.client.HttpRequest sendAsync HttpRequest.java 780]
  [org.eclipse.jetty.client.HttpRequest send HttpRequest.java 767]
  [cognitect.http_client.Client$fn__20661 invoke http_client.clj 252]
  [cognitect.http_client.Client submit_STAR_ http_client.clj 236]
  [cognitect.http_client$submit invokeStatic http_client.clj 223]
  [cognitect.http_client$submit invoke http_client.clj 186]
  [cognitect.aws.http.cognitect$create$reify__20689 _submit cognitect.clj 15]
  [cognitect.aws.http$submit invokeStatic http.clj 48]
  [cognitect.aws.http$submit invoke http.clj 44]
  [cognitect.aws.client.impl$send_request$fn__20306$state_machine__6741__auto____20335$fn__20337$fn__20351 invoke impl.clj 80]
  [cognitect.aws.client.impl$send_request$fn__20306$state_machine__6741__auto____20335$fn__20337 invoke impl.clj 72]
  [cognitect.aws.client.impl$send_request$fn__20306$state_machine__6741__auto____20335 invoke impl.clj 60]
  [clojure.core.async.impl.ioc_macros$run_state_machine invokeStatic ioc_macros.clj 973]
  [clojure.core.async.impl.ioc_macros$run_state_machine invoke ioc_macros.clj 972]
  [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invokeStatic ioc_macros.clj 977]
  [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invoke ioc_macros.clj 975]
  [cognitect.aws.client.impl$send_request$fn__20306 invoke impl.clj 60]
  [clojure.lang.AFn run AFn.java 22]
  [java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 628]
  [java.lang.Thread run Thread.java 829]]}}

The workaround is to change the engine, such as tomcat, that it works as expected:

(defn create-server []
  (http/create-server
    {::http/routes routes
     ::http/type   :tomcat
     ::http/port   3030}))

Thus using:

;;
[io.pedestal/pedestal.tomcat "0.5.3"]
;;
dchelimsky commented 1 year ago

Hey @deafjava !!!! Thanks for the report.

The problem is a transitive dependency conflict on jetty-io, which you can resolve by upgrading to pedestal 5.10. Please give that a try and I'll leave this open until I hear back from you.

deafjava commented 1 year ago

Oh, it worked! Many thanks! Forgot to add a workflow to bump dependencies 😬 💜