{"record":{"id":"a62211819f168cd1","repo":"opendataloader-project/opendataloader-pdf","slug":"could-not-find-the-jar-file-please-run-mvn-packa","errorCode":null,"errorMessage":"Could not find the JAR file. Please run 'mvn package' in the 'java/' directory first. Searched in: {resolved_glob_path}","messagePattern":"Could not find the JAR file\\. Please run 'mvn package' in the 'java/' directory first\\. Searched in: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/opendataloader-pdf/hatch_build.py","lineNumber":47,"sourceCode":"            and license_path.exists()\n            and notice_path.exists()\n            and third_party_dest.exists()\n            and readme_path.exists()\n        ):\n            print(\"All required files already exist (building from sdist), skipping copy\")\n            return\n\n        # --- Copy JAR ---\n        print(f\"Root DIR: {root_dir}\")\n        source_jar_glob = str(\n            root_dir / \"../../java/opendataloader-pdf-cli/target/opendataloader-pdf-cli-*.jar\"\n        )\n        resolved_glob_path = Path(source_jar_glob).resolve()\n        print(f\"Searching for JAR file in: {resolved_glob_path}\")\n\n        source_jar_paths = glob.glob(source_jar_glob)\n        if not source_jar_paths:\n            raise RuntimeError(\n                f\"Could not find the JAR file. Please run 'mvn package' in the 'java/' directory first. Searched in: {resolved_glob_path}\"\n            )\n        if len(source_jar_paths) > 1:\n            raise RuntimeError(f\"Found multiple JAR files, expected one: {source_jar_paths}\")\n        source_jar_path = source_jar_paths[0]\n        print(f\"Found source JAR: {source_jar_path}\")\n\n        dest_jar_dir.mkdir(parents=True, exist_ok=True)\n        print(f\"Copying JAR to {dest_jar_path}\")\n        shutil.copy(source_jar_path, dest_jar_path)\n\n        # --- Copy LICENSE, NOTICE ---\n        # README is copied by build-python.sh before this hook runs, because\n        # hatchling validates [project.readme] during metadata parsing, which\n        # happens before build hooks. Do not copy README here.\n        shutil.copy(root_dir / \"../../LICENSE\", license_path)\n        shutil.copy(root_dir / \"../../NOTICE\", notice_path)\n        third_party_src = root_dir / \"../../THIRD_PARTY\"","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/python/opendataloader-pdf/hatch_build.py#L29-L65","documentation":"RuntimeError raised by the hatch build hook when glob.glob found ZERO jars matching java/opendataloader-pdf-cli/target/opendataloader-pdf-cli-*.jar. The Python wheel packages the prebuilt CLI jar, so the hook requires that Maven has already produced it. The message prints the resolved glob path so you can see exactly where it looked.","triggerScenarios":"Running pip install / hatch build / python -m build on the opendataloader-pdf package WITHOUT having first run mvn package in the java/ directory, so target/ has no jar (or target/ does not exist).","commonSituations":"Fresh clone where only the Python package is being built. CI that builds the wheel before the Maven step. Building from an sdist that did not include the jar. A clean that wiped target/.","solutions":["Build the jar first: run mvn package (or mvn -DskipTests package) in the java/ directory, then rebuild the wheel.","Confirm the produced jar path matches the glob: ls java/opendataloader-pdf-cli/target/opendataloader-pdf-cli-*.jar.","In CI, order the Maven build step before the Python build step and fail fast if Maven fails.","If building from sdist, ensure the sdist was generated after a successful Maven build."],"exampleFix":"# before: wheel build with no jar\n$ pip install .  # -> RuntimeError: Could not find the JAR file...\n# after: build jar first, then wheel\n$ (cd java && mvn -DskipTests package)\n$ pip install .","handlingStrategy":"validation","validationCode":"# Pre-build check in your build script:\nfrom pathlib import Path\nimport glob\njar = glob.glob(\"java/opendataloader-pdf-cli/target/opendataloader-pdf-cli-*.jar\")\nassert len(jar) == 1, f\"Expected exactly 1 jar, found {len(jar)}; run: (cd java && mvn -DskipTests package)\"\n","typeGuard":"def is_missing_jar_error(exc: RuntimeError) -> bool:\n    return isinstance(exc, RuntimeError) and \"Could not find the JAR file\" in str(exc)","tryCatchPattern":"# In CI: build jar first, fail fast if absent, then build the wheel.\n#   (cd java && mvn -DskipTests package) && pip install .\n# If hit at runtime:\ntry:\n    import opendataloader_pdf\nexcept RuntimeError as e:\n    if \"Could not find the JAR file\" in str(e):\n        raise SystemExit(\"Run (cd java && mvn package) then reinstall\")\n    raise","preventionTips":["Always run mvn package in java/ before building the Python wheel.","Order CI steps: Maven build, then Python build, fail fast if Maven fails.","When building from sdist, ensure the sdist was produced after a successful Maven build."],"tags":["build","hatch","maven","jar","packaging"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}