{"record":{"id":"e753af1e083e5d0e","repo":"cube-js/cube","slug":"unable-to-resolve-maven-dependencies-mvn-exited-w","errorCode":null,"errorMessage":"Unable to resolve maven dependencies, mvn exited with: \"${mvnOutput.status}\" code","messagePattern":"Unable to resolve maven dependencies, mvn exited with: \"(.+?)\" code","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-maven/src/maven.ts","lineNumber":150,"sourceCode":"    }\n  }\n\n  return getExternalMaven();\n}\n\nasync function installDependencies(pathToPom: string, options: ResolveOptions) {\n  const { binary } = await getMaven(options);\n\n  // https://search.maven.org/artifact/de.qaware.maven/go-offline-maven-plugin/1.2.8/jar\n  const mvnOutput = spawnSync(binary, ['de.qaware.maven:go-offline-maven-plugin:1.2.8:resolve-dependencies', '-f', pathToPom], {\n    stdio: options.showOutput ? 'inherit' : 'pipe',\n    encoding: 'utf8'\n  });\n  if (mvnOutput.status === 0) {\n    return;\n  }\n\n  throw new Error(\n    `Unable to resolve maven dependencies, mvn exited with: \"${mvnOutput.status}\" code`\n  );\n}\n\nexport async function resolveDependencies(dependecies: MavenDependency[], options: ResolveOptions) {\n  const pathToPom = path.resolve(os.tmpdir(), 'cubejs-pom.xml');\n\n  fs.writeFileSync(pathToPom, generateXml(dependecies));\n\n  await installDependencies(pathToPom, options);\n}\n\nexport function getDependenciesFromPackage(): MavenDependency[] {\n  const pathToLock = path.join(process.cwd(), 'package.json');\n\n  if (!fs.existsSync(pathToLock)) {\n    throw new Error(\n      `Unable to find package.json file in current working directory: ${process.cwd()}`","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-maven/src/maven.ts#L132-L168","documentation":"@cubejs-backend-maven shells out to the `mvn` CLI to resolve Java dependencies (e.g. for JDBC drivers). If the maven process exits with a non-zero status, dependency resolution failed and the library surfaces mvn's exit code. It indicates mvn itself ran but could not resolve/download the dependencies.","triggerScenarios":"Calling installDependencies (via resolveDependencies) when the spawned `mvn dependency:...` command exits with any status other than 0 — e.g. missing dependencies, bad pom, no network to Maven Central.","commonSituations":"Offline/behind-proxy environments where Maven Central is unreachable; corrupted or partial ~/.m2 cache; invalid version coordinates in the maven dependencies list; mvn installed but misconfigured (settings.xml issues); Java/JDK not on PATH causing mvn to fail.","solutions":["Run `mvn` manually with the same goal (check the generated cubejs-pom.xml in os.tmpdir()) to see the real error output.","Ensure network/proxy access to Maven Central (or configure mirrors in ~/.m2/settings.xml).","Verify the maven dependency coordinates (groupId/artifactId/version) passed to resolveDependencies are valid.","Confirm `mvn -v` works and a compatible JDK is installed."],"exampleFix":"// before\nawait resolveDependencies([{ artifactId: 'mysql-connector', version: '99' }], options);\n\n// after\nawait resolveDependencies([{ groupId: 'com.mysql', artifactId: 'mysql-connector-j', version: '8.0.33' }], options);","handlingStrategy":"try-catch","validationCode":"const { execFileSync } = require('child_process');\ntry {\n  execFileSync('mvn', ['-v'], { stdio: 'ignore' });\n} catch {\n  throw new Error('mvn must be installed and on PATH before resolving maven dependencies');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await resolveDependencies(deps, options);\n} catch (e) {\n  if (/Unable to resolve maven dependencies/.test(e.message)) {\n    console.error('mvn failed; run the maven goal manually for full logs and check proxy/credentials.');\n  } else throw e;\n}","preventionTips":["Verify mvn and a JDK are installed and on PATH before starting the Cube server.","Test network access to Maven Central (or configure settings.xml mirrors/proxy).","Pin valid dependency coordinates and versions in your driver config."],"tags":["maven","java","dependency-resolution","subprocess"],"backgroundTag":"maven-dependency-resolution-failed","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}