{"record":{"id":"6278c648ffb68496","repo":"quarkusio/quarkus","slug":"java-lang-runtimeexception-6278c6","errorCode":null,"errorMessage":"java.lang.RuntimeException","messagePattern":"java\\.lang\\.RuntimeException","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/ApplicationModelSerializer.java","lineNumber":165,"sourceCode":"     */\n    private static void serializeWithJos(ApplicationModel appModel, Path file) throws IOException {\n        try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(file))) {\n            out.writeObject(appModel);\n        }\n    }\n\n    /**\n     * Deserializes an {@link ApplicationModel} from a file with Java Object Serialization.\n     *\n     * @param file file to read an application model from\n     * @return deserialized application model\n     * @throws IOException in case of a failure\n     */\n    private static ApplicationModel deserializeWithJos(Path file) throws IOException {\n        try (InputStream existing = Files.newInputStream(file)) {\n            return (ApplicationModel) new ObjectInputStream(existing).readObject();\n        } catch (ClassNotFoundException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    /**\n     * Serialize an {@link ApplicationModel} to a JSON file.\n     *\n     * @param appModel application model to serialize\n     * @param file target file\n     * @throws IOException in case of a failure\n     */\n    private static void toJson(ApplicationModel appModel, Path file) throws IOException {\n        writeJson((Json.JsonObjectBuilder) appModel.asMap(JSON_CONTAINER_FACTORY), file);\n    }\n\n    /**\n     * Serializes a {@link io.quarkus.bootstrap.json.Json.JsonObjectBuilder} to a JSON file.\n     *\n     * @param jsonObject JSON object builder","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/ApplicationModelSerializer.java#L147-L183","documentation":"deserializeWithJos reads an application model file using Java object serialization (ObjectInputStream) and wraps ClassNotFoundException in a RuntimeException. The serialized stream references classes not present on the current classpath — usually because the model classes changed between Quarkus versions or the wrong classloader is in play.","triggerScenarios":"Calling deserialize on a cached \"jos\"-format application model file whose stream contains classes that cannot be loaded — typically a stale cache written by a different Quarkus version.","commonSituations":"Upgrading Quarkus while an old serialized app-model cache remains on disk, mixing Quarkus versions on the classpath, or deserializing in a classloader (isolated deployment) that cannot see the serialized classes.","solutions":["Delete the stale serialized application model cache file and re-run so it is regenerated","Ensure the Quarkus version that reads the cache matches the version that wrote it","Use the \"json\" serialization format instead of \"jos\" for version-tolerant caching"],"exampleFix":"// before\nrm -rf target/quarkus-bootstrap // stale jos cache from old version\nmvn quarkus:dev\n// after\nmvn quarkus:dev // cache regenerated with current classes (or switch format to json)","handlingStrategy":"fallback","validationCode":"// skip jos cache if written by a different Quarkus version\nString cacheVersion = readCacheMetaVersion(file);\nif (!cacheVersion.equals(currentQuarkusVersion)) { Files.deleteIfExists(file); }","typeGuard":null,"tryCatchPattern":"try {\n    model = serializer.deserialize(file);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof ClassNotFoundException) {\n        Files.deleteIfExists(file); // drop stale cache and re-serialize\n    }\n}","preventionTips":["Delete bootstrap caches when upgrading Quarkus","Prefer the json serialization format over jos","Avoid mixing Quarkus versions across modules"],"tags":["serialization","classpath","cache","classnotfound"],"backgroundTag":"classnotfound-deserialization","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}