{"record":{"id":"4816c5738f1d5362","repo":"apache/beam","slug":"error-in-startautomatedjavaexpansionservice-s-s-w","errorCode":null,"errorMessage":"error in  startAutomatedJavaExpansionService(%s,%s): %w","messagePattern":"error in  startAutomatedJavaExpansionService\\((.+?),(.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/expand.go","lineNumber":214,"sourceCode":"\treturn res, nil\n}\n\nfunc startAutomatedJavaExpansionService(gradleTarget string, classpath string) (stopFunc func() error, address string, err error) {\n\tjarPath, err := expansionx.GetBeamJar(gradleTarget, core.SdkVersion)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tif len(classpath) > 0 {\n\t\tjarPath, err = expansionx.MakeJar(jarPath, classpath)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", err\n\t\t}\n\t}\n\n\tserviceRunner, err := expansionx.NewExpansionServiceRunner(jarPath, \"\")\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"error in  startAutomatedJavaExpansionService(%s,%s): %w\", gradleTarget, classpath, err)\n\t}\n\terr = serviceRunner.StartService()\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"error in starting expansion service, StartService(): %w\", err)\n\t}\n\tstopFunc = serviceRunner.StopService\n\taddress = serviceRunner.Endpoint()\n\treturn stopFunc, address, nil\n}\n\n// QueryAutomatedExpansionService submits an external transform to be expanded by the\n// expansion service and then eagerly materializes the artifacts for staging. The given\n// transform should be the external transform, and the components are any additional\n// components necessary for the pipeline snippet.\n//\n// The address to be queried is determined by the Config field of the HandlerParams after\n// the prefix tag indicating the automated service is in use.\nfunc QueryAutomatedExpansionService(ctx context.Context, p *HandlerParams) (*jobpb.ExpansionResponse, error) {","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/expand.go#L196-L232","documentation":"startAutomatedJavaExpansionService downloads/prepares the expansion service jar (NewExpansionServiceRunner) before launching it. If constructing the runner fails — jar resolution, gradle target lookup, or local setup issues — this error wraps the cause along with the gradle target and classpath used.","triggerScenarios":"Calling QueryAutomatedExpansionService which invokes startAutomatedJavaExpansionService when NewExpansionServiceRunner(jarPath, \"\") returns an error: missing jar, failed gradle resolution of the target, or invalid classpath/environment.","commonSituations":"No local Gradle/Java toolchain, offline environments where the jar cannot be fetched, wrong gradleCoordinates target for the transform, or filesystem permission issues when staging the jar.","solutions":["Check the wrapped error and the reported gradle target/classpath; verify the target coordinates are correct.","Ensure Java and Gradle are installed and reachable (JAVA_HOME, PATH).","Pre-download or cache the expansion service jar to avoid network resolution at runtime.","Use an external (pre-started) expansion service endpoint instead of automated expansion.","Check disk space/permissions in the directory where the jar is staged."],"exampleFix":"// before\nres, err := xlangx.QueryAutomatedExpansionService(ctx, req, nil, gradleTarget) // no Java env\n// after\n// point at a running service instead\nres, err := xlangx.Expand(ctx, req, nil, \"localhost:8097\")","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"java\"); err != nil {\n\treturn fmt.Errorf(\"automated expansion requires Java on PATH: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"stop, addr, err := xlangx.QueryAutomatedExpansionService(ctx, req, o, target)\nif err != nil {\n\treturn fmt.Errorf(\"automated expansion failed (%v); start a service manually and use xlangx.Expand\", err)\n}\ndefer stop()","preventionTips":["Install and verify Java/Gradle before using automated expansion.","Pre-fetch and cache the expansion jar for offline/CI environments.","Prefer a pre-started external expansion service in production."],"tags":["xlang","expansion-service","java","process","beam","go"],"backgroundTag":"module-init-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}