{"record":{"id":"2f68f1b2120eff27","repo":"hibernate/hibernate-orm","slug":"could-not-find-specified-jar-file-jarfilereferen","errorCode":null,"errorMessage":"Could not find specified jar-file: <jarFileReference>","messagePattern":"Could not find specified jar-file: <jarFileReference>","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/archive/internal/ArchiveHelper.java","lineNumber":173,"sourceCode":"\t}\n\n\tprivate static URL tryAsFileReference(String jarFileReference, String trimmed) {\n\t\tfinal File jarFile = new File( trimmed );\n\t\ttry {\n\t\t\tif ( jarFile.exists() ) {\n\t\t\t\treturn jarFile.toURI().toURL();\n\t\t\t}\n\t\t}\n\t\tcatch (MalformedURLException ignore) {\n\t\t}\n\t\treturn null;\n\t}\n\n\n\tpublic static URL asFileReference(String jarFileReference, String trimmed) {\n\t\tfinal File jarFile = new File( trimmed );\n\t\tif ( !jarFile.exists() ) {\n\t\t\tthrow new HibernateException( \"Could not find specified jar-file: \" + jarFileReference );\n\t\t}\n\t\ttry {\n\t\t\treturn jarFile.toURI().toURL();\n\t\t}\n\t\tcatch (MalformedURLException e) {\n\t\t\tthrow new HibernateException( \"Could not access specified jar-file: \" + jarFileReference, e );\n\t\t}\n\t}\n\n\t/// Extracts the bytes out of an InputStream.  This form is the same as [#getBytesFromInputStream]\n\t/// except that any [IOException] is wrapped as (runtime) [ArchiveException]\n\t///\n\t/// @param inputStream The stream from which to extract bytes.\n\t///\n\t/// @return The bytes\n\t///\n\t/// @throws ArchiveException Indicates a problem accessing the stream\n\tpublic static byte[] getBytesFromInputStreamSafely(InputStream inputStream) throws ArchiveException {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/archive/internal/ArchiveHelper.java#L155-L191","documentation":"ArchiveHelper.asFileReference converts a jar-file reference into a file-based URL and requires File.exists(); when the named file is absent it throws HibernateException 'Could not find specified jar-file'. Unlike the resolveJarFileReference path there is no classloader fallback here — the reference is treated strictly as a filesystem location.","triggerScenarios":"A jar-file reference that reaches asFileReference but points to a file that does not exist at startup time: deleted artifact, wrong working directory, or a path valid only in another environment.","commonSituations":"Paths hardcoded for one machine; build outputs renamed between environments; cleanup scripts or hot redeploys removing jars before Hibernate starts.","solutions":["Verify the location with Files.exists and correct the reference to the real jar path.","Rebuild/redeploy the artifact so the jar is present where the reference expects it.","Use absolute paths or classpath-relative references instead of environment-dependent relative ones."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Path p = Paths.get(jarFileReference);\nif (!Files.exists(p)) {\n    throw new IllegalStateException(\"Configured jar-file does not exist: \" + p.toAbsolutePath());\n}","typeGuard":null,"tryCatchPattern":"Catch org.hibernate.HibernateException around archive setup; on 'Could not find specified jar-file', log the absolute expected path and the current working directory to pinpoint the mismatch.","preventionTips":["Check Files.exists for configured jar paths at startup with a clear error message.","Avoid environment-dependent relative paths in deployment descriptors."],"tags":["hibernate","jar-file","file-not-found","deployment","classpath"],"backgroundTag":"jar-file-not-found","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}