quarkusio/quarkus · error · RuntimeException

java.lang.RuntimeException

Error message

java.lang.RuntimeException

What it means

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.

Source

Thrown at independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/ApplicationModelSerializer.java:165

     */
    private static void serializeWithJos(ApplicationModel appModel, Path file) throws IOException {
        try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(file))) {
            out.writeObject(appModel);
        }
    }

    /**
     * Deserializes an {@link ApplicationModel} from a file with Java Object Serialization.
     *
     * @param file file to read an application model from
     * @return deserialized application model
     * @throws IOException in case of a failure
     */
    private static ApplicationModel deserializeWithJos(Path file) throws IOException {
        try (InputStream existing = Files.newInputStream(file)) {
            return (ApplicationModel) new ObjectInputStream(existing).readObject();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Serialize an {@link ApplicationModel} to a JSON file.
     *
     * @param appModel application model to serialize
     * @param file target file
     * @throws IOException in case of a failure
     */
    private static void toJson(ApplicationModel appModel, Path file) throws IOException {
        writeJson((Json.JsonObjectBuilder) appModel.asMap(JSON_CONTAINER_FACTORY), file);
    }

    /**
     * Serializes a {@link io.quarkus.bootstrap.json.Json.JsonObjectBuilder} to a JSON file.
     *
     * @param jsonObject JSON object builder

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the stale serialized application model cache file and re-run so it is regenerated
  2. Ensure the Quarkus version that reads the cache matches the version that wrote it
  3. Use the "json" serialization format instead of "jos" for version-tolerant caching

Example fix

// before
rm -rf target/quarkus-bootstrap // stale jos cache from old version
mvn quarkus:dev
// after
mvn quarkus:dev // cache regenerated with current classes (or switch format to json)
Defensive patterns

Strategy: fallback

Validate before calling

// skip jos cache if written by a different Quarkus version
String cacheVersion = readCacheMetaVersion(file);
if (!cacheVersion.equals(currentQuarkusVersion)) { Files.deleteIfExists(file); }

Try / catch

try {
    model = serializer.deserialize(file);
} catch (RuntimeException e) {
    if (e.getCause() instanceof ClassNotFoundException) {
        Files.deleteIfExists(file); // drop stale cache and re-serialize
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/6278c648ffb68496. Report an issue: GitHub.