{"id":15805079,"url":"https://github.com/ddobrin/word-count-beam-native-java","last_synced_at":"2025-03-31T22:09:16.249Z","repository":{"id":134175926,"uuid":"598156083","full_name":"ddobrin/word-count-beam-native-java","owner":"ddobrin","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-06T22:47:28.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-06T02:04:15.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddobrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-06T14:21:02.000Z","updated_at":"2023-02-06T15:24:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb883579-ed33-4f52-a46c-b0653157951a","html_url":"https://github.com/ddobrin/word-count-beam-native-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fword-count-beam-native-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fword-count-beam-native-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fword-count-beam-native-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fword-count-beam-native-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddobrin","download_url":"https://codeload.github.com/ddobrin/word-count-beam-native-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246547366,"owners_count":20794970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T02:03:44.326Z","updated_at":"2025-03-31T22:09:16.216Z","avatar_url":"https://github.com/ddobrin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build a Native Java image for an Apache Beam data pipeline\n\nEnvironment\n```\n# Java 17 + GraalVM 22.3.x\nopenjdk version \"17.0.5\" 2022-10-18\nOpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)\nOpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)\n```\n\nBuild the JIT app image\n1. ```./mvnw clean package``` \n\n2. Run the pipeline from the CLI\n```\njava -agentlib:native-image-agent=config-output-dir=target/native-image -cp target/word-count-beam-bundled-0.1.jar  org.apache.beam.examples.WordCount --output=counts --inputFile=pom.xml\n\n# Params: \nMain class: org.apache.beam.examples.WordCount\nInput: pom.xml (count the words in this file)\nOutput: word + count\n```\n\n3. copy the `JSON files` from `target/native-image` folder to `src\\main\\resources\\META-INF\\services\n\n4. build the JIT app image with the META-INF configuration ```./mvnw clean package``` \n\n5. build the native image\n```\n native-image  -cp target/word-count-beam-bundled-0.1.jar org.apache.beam.examples.WordCount\n ```\n\n 6. start the native image \n ```\n ./org.apache.beam.examples.wordcount --output=counts --inputFile=pom.xml\n ```\n\n ## Challenge - to resolve - proxy errors\n An error occcurs:\n ```Exception in thread \"main\" com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.beam.runners.direct.DirectTestOptions, interface org.apache.beam.runners.portability.testing.TestUniversalRunner$Options, interface org.apache.beam.runners.direct.DirectOptions, interface org.apache.beam.sdk.extensions.gcp.options.GcpOptions, interface org.apache.beam.runners.portability.testing.TestPortablePipelineOptions] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles=\u003ccomma-separated-config-files\u003e and -H:DynamicProxyConfigurationResources=\u003ccomma-separated-config-resources\u003e options.\n\tat org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)\n\tat org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:171)\n\tat java.base@17.0.5/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:47)\n\tat java.base@17.0.5/java.lang.reflect.Proxy.getProxyClass(Proxy.java:398)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.validateWellFormed(PipelineOptionsFactory.java:2165)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.validateWellFormed(PipelineOptionsFactory.java:2108)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.register(PipelineOptionsFactory.java:2103)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.initializeRegistry(PipelineOptionsFactory.java:2091)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.\u003cinit\u003e(PipelineOptionsFactory.java:2083)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.\u003cinit\u003e(PipelineOptionsFactory.java:2047)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory.resetCache(PipelineOptionsFactory.java:581)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory.\u003cclinit\u003e(PipelineOptionsFactory.java:547)\n\tat org.apache.beam.examples.WordCount.main(WordCount.java:205)\n```\n\nAdd the missing proxy to the /META-INF/services/proxy-config.json\n```json\n{\n    \"interfaces\": [\"org.apache.beam.runners.direct.DirectTestOptions\",\"org.apache.beam.runners.portability.testing.TestUniversalRunner$Options\",\"org.apache.beam.runners.direct.DirectOptions\",\"org.apache.beam.sdk.extensions.gcp.options.GcpOptions\",\"org.apache.beam.runners.portability.testing.TestPortablePipelineOptions\"]\n}\n```\n\nRebuild the JIT image and native image\n```./mvnw clean package``` \n\n```\n native-image  -cp target/word-count-beam-bundled-0.1.jar org.apache.beam.examples.WordCount\n ```\n\n## Repeated - the next failure occurs --\u003e how to identify the missing proxies, to be resolved\n```\n./org.apache.beam.examples.wordcount --output=counts --inputFile=pom.xml\nException in thread \"main\" com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.beam.runners.direct.DirectTestOptions, interface org.apache.beam.runners.portability.testing.TestPortablePipelineOptions, interface org.apache.beam.runners.portability.testing.TestUniversalRunner$Options, interface org.apache.beam.runners.direct.DirectOptions] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles=\u003ccomma-separated-config-files\u003e and -H:DynamicProxyConfigurationResources=\u003ccomma-separated-config-resources\u003e options.\n\tat org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)\n\tat org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:171)\n\tat java.base@17.0.5/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:47)\n\tat java.base@17.0.5/java.lang.reflect.Proxy.getProxyClass(Proxy.java:398)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.validateWellFormed(PipelineOptionsFactory.java:2165)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.validateWellFormed(PipelineOptionsFactory.java:2108)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.register(PipelineOptionsFactory.java:2103)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.initializeRegistry(PipelineOptionsFactory.java:2091)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.\u003cinit\u003e(PipelineOptionsFactory.java:2083)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory$Cache.\u003cinit\u003e(PipelineOptionsFactory.java:2047)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory.resetCache(PipelineOptionsFactory.java:581)\n\tat org.apache.beam.sdk.options.PipelineOptionsFactory.\u003cclinit\u003e(PipelineOptionsFactory.java:547)\n\tat org.apache.beam.examples.WordCount.main(WordCount.java:205)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fword-count-beam-native-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddobrin%2Fword-count-beam-native-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fword-count-beam-native-java/lists"}