{"record":{"id":"ce32a64ea93f9d41","repo":"apache/beam","slug":"no-code-generation-strategy-available-ce32a6","errorCode":null,"errorMessage":"No code generation strategy available","messagePattern":"No code generation strategy available","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/ByteBuddyUtils.java","lineNumber":59,"sourceCode":"      try {\n        Class<?> methodHandles = Class.forName(\"java.lang.invoke.MethodHandles\", true, classLoader);\n        @SuppressWarnings(\"nullness\") // MethodHandles#lookup accepts null\n        Object lookup = methodHandles.getMethod(\"lookup\").invoke(null);\n        Class<?> lookupClass =\n            Class.forName(\"java.lang.invoke.MethodHandles$Lookup\", true, classLoader);\n        Method privateLookupIn =\n            methodHandles.getMethod(\"privateLookupIn\", Class.class, lookupClass);\n        @SuppressWarnings(\"nullness\") // this is a static method, the receiver can be null\n        Object privateLookup = requireNonNull(privateLookupIn.invoke(null, targetClass, lookup));\n        strategy = ClassLoadingStrategy.UsingLookup.of(requireNonNull(privateLookup));\n      } catch (ReflectiveOperationException e) {\n        throw new IllegalStateException(\n            \"No code generation strategy available \" + targetClass + \" \" + classLoader, e);\n      }\n    } else if (ClassInjector.UsingReflection.isAvailable()) {\n      strategy = ClassLoadingStrategy.Default.INJECTION;\n    } else {\n      throw new IllegalStateException(\"No code generation strategy available\");\n    }\n    return strategy;\n  }\n}\n","sourceCodeStart":41,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/ByteBuddyUtils.java#L41-L64","documentation":"This is the terminal fallback in getClassLoadingStrategy: when neither MethodHandles.privateLookupIn-based loading applies nor ByteBuddy's reflection-based ClassInjector (ClassInjector.UsingReflection) is available, there is no way to load generated classes, so the method throws IllegalStateException. It indicates the runtime JVM blocks all ByteBuddy class-injection mechanisms.","triggerScenarios":"Running on a JDK where ClassInjector.UsingReflection.isAvailable() returns false (Java 9+ with strong encapsulation where reflection into JDK class loaders is blocked) and no lookup-based strategy was obtainable.","commonSituations":"Running Beam on Java 16+ without --add-opens java.base/java.lang=ALL-UNNAMED; container images with hardened JDKs; using outdated ByteBuddy versions on new JDKs.","solutions":["Add JVM flag --add-opens java.base/java.lang=ALL-UNNAMED so UsingReflection becomes available","Upgrade the byte-buddy dependency to the latest version compatible with your JDK","Run on a JDK version officially supported by the Beam release","Check that ClassInjector.UsingReflection.isAvailable() passes in a smoke test before deploying"],"exampleFix":"// before\njava -jar pipeline.jar\n// IllegalStateException: No code generation strategy available\n// after\njava --add-opens java.base/java.lang=ALL-UNNAMED -jar pipeline.jar","handlingStrategy":"validation","validationCode":"if (!ClassInjector.UsingReflection.isAvailable()) {\n  throw new IllegalStateException(\n      \"Add --add-opens java.base/java.lang=ALL-UNNAMED to JVM args\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always launch with --add-opens java.base/java.lang=ALL-UNNAMED on Java 16+","Test on the actual runner/container JDK before release","Avoid hardened JDK builds that strip reflection capabilities","Upgrade byte-buddy regularly"],"tags":["java","reflection","bytebuddy","classloading","jpms"],"backgroundTag":"unsupported-platform","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}