graalvm

Bruno do Nascimento Maciel 2024-11-26T22:55:34.961179Z

Hey folks, I am trying to bump the dependencies for aws-api-s3 I am able to generate the image but when I run the binary I am getting:

Exception in thread "main" clojure.lang.ExceptionInfo: Cannot find resource cognitect/aws/s3/service.edn. {}
        at cognitect.aws.service$service_description.invokeStatic(service.clj:32)
        at cognitect.aws.service$service_description.invoke(service.clj:29)
        at cognitect.aws.client.api$client.invokeStatic(api.clj:73)
        at cognitect.aws.client.api$client.invoke(api.clj:24)
        at simple.main$_main.invokeStatic(main.clj:16)
        at simple.main$_main.invoke(main.clj:13)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at simple.main.main(Unknown Source)
        at java.base@23/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
I am implementing the changes https://github.com/macielti/graalvm-clojure/blob/bump-aws-api-s3/aws-api-s3/project.clj. What is the correct way to load this missing resource?

souenzzo 2024-11-27T10:02:23.946289Z

your ResourceConfigurationFiles// resource-config.json is not including the cognitect/aws/s3/service.edn file checkout https://clojurians.slack.com/archives/CAJN79WNT/p1730395014839369

Bruno do Nascimento Maciel 2024-11-27T11:44:44.300749Z

nice, I was able to fix this using this as the resource files configuration:

{
  "resources": {
    "includes": [
      {
        "pattern": "cognitect/aws/.+\\.edn"
      }
    ]
  }
}

Bruno do Nascimento Maciel 2024-11-27T11:53:09.885969Z

and after that it was asking by the Could not find cognitect_aws_http.edn on classpath

Bruno do Nascimento Maciel 2024-11-27T11:54:25.674619Z

I will try to also include the cognitect_aws_http.edn with in the resource files configuration.

Bruno do Nascimento Maciel 2024-11-27T11:55:36.049419Z

It worked!!! gratitude

{
  "resources": {
    "includes": [
      {
        "pattern": "cognitect/aws/.+\\.edn"
      },
      {
        "pattern" : "cognitect_aws_http.edn"
      }
    ]
  }
}

Bruno do Nascimento Maciel 2024-11-27T11:56:15.937969Z

👍 1
souenzzo 2024-11-27T11:56:21.838909Z

Try to use the GraalVM with tracing agent. With GraalVM tracing agent, you can run your JAR, the VM will track down all resources and reflections, and generate the configuration for you. • write your app and create an uberjar • Start your app.jar using https://www.graalvm.org/latest/reference-manual/native-image/guides/configure-with-tracing-agent/ • Use your app. At least, one read and one write on s3 • Stop your app • Checkout the filter.json and the others files generated by the tracing agent • Add all reflections reported by the tracing agent to your native-image using -H:ReflectionConfigurationFiles=reflect-config.json and -H:ResourceConfigurationFiles=resource-config.json

Bruno do Nascimento Maciel 2024-11-27T11:57:39.133389Z

I tried to use it but I want to push to the minimal required configuration. the tracing agent returns a lot of stuff.

👍 1
souenzzo 2024-11-27T11:59:47.317569Z

Btw, I used to do these steps inside the CI and use the generated reflect-config.json dynamically, without commit the huge file.

Bruno do Nascimento Maciel 2024-11-27T12:01:17.955159Z

that is a good idea

souenzzo 2024-11-27T12:03:01.384759Z

here is a reference for you (also, a 🇧🇷 project 😉 ) https://github.com/moclojer/moclojer/blob/main/.github/workflows/build-native-image.yml#L28C19-L36

Bruno do Nascimento Maciel 2024-11-27T12:07:33.968529Z

This will help me a lot. I am also building native image inside CI but the process I taking too long to complete. I need some optimization references.

souenzzo 2024-11-27T12:12:08.682429Z

If the project is open source, https://github.com/moclojer/moclojer/pull/21

Bruno do Nascimento Maciel 2024-11-27T15:18:45.078179Z

https://github.com/clj-easy/graalvm-clojure/pull/67 reviewplease @borkdude what do you think?

borkdude 2024-11-27T15:33:34.183619Z

@brunodonascimentomaci looks good I think. why did it work before without the resources configuration though? sidenote: if you want a quick starting aws api this also works with bb:

borkdude 2024-11-27T15:33:35.938029Z

https://github.com/grzm/awyeah-api

Bruno do Nascimento Maciel 2024-11-27T15:35:25.429939Z

I am not sure if it could be related with bumping the dependencies to the latest version or using GraalVM 23 instead of the older versions.

Bruno do Nascimento Maciel 2024-11-27T15:39:30.281469Z

Can I use it with Leiningen? I am not sure if it supports dependencies via git repository, in a way that it is compatible with the native image building process.

borkdude 2024-11-27T15:45:10.725909Z

nope, lein does not support git deps

borkdude 2024-11-27T15:45:49.818319Z

I mean, awyeah-api works with bb, so then you wouldn't need graalvm. That's what I wanted to say, I didn't mean to change to PR, just a side note

Bruno do Nascimento Maciel 2024-11-27T15:58:41.662489Z

Nice. I asked because I intent to use this AWS s3 integration inside a project that uses Leiningen.