graalvm

agorgl 2022-11-08T21:16:42.603959Z

Has anybody built GraalVM native-image binaries for pedestal projects that use static resources? I get java.lang.IllegalArgumentException in Interceptor :io.pedestal.http.ring-middlewares/resource - No method in multimethod 'resource-data' for dispatch value: :resource when trying to access the static content I added -H:IncludeResources=public/.* -H:Log=registerResource:3 to the native-image flags

agorgl 2022-11-09T08:39:33.926479Z

Ah nice thanks! I suppose I fall in the list with all the others waiting for this to merge: https://github.com/ring-clojure/ring/pull/447

borkdude 2022-11-09T08:57:30.188459Z

You can just do this in user space

borkdude 2022-11-09T08:57:42.657639Z

This problem has been discussed before in this channel

2022-11-08T22:49:37.973119Z

Likely due to https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/response.clj#L292 usually when you look up a resource, the url you get is a jar:// but looks like on Graal you get a resource:// and the multimethod there doesn't understand that

2022-11-14T20:47:40.383689Z

@agorglouk as borkdude says, you can fix this in your project with:

(defmethod resource-data :resource
  [^java.net.URL url]
  ;; GraalVM resource scheme
  (let [resource     (.openConnection url)]
    {:content        (.getInputStream resource)
     :content-length (connection-content-length resource)
     :last-modified  (connection-last-modified resource)}))
along with the 2 methods above that in the ring code <https://github.com/ring-clojure/ring/pull/447/files>