quarkusio/quarkus · error · AppModelResolverException

Failed to deserialize quarkus model

Error message

Failed to deserialize quarkus model

What it means

BootstrapUtils.deserializeQuarkusModel() reads a previously serialized ApplicationModel from disk (used as a dev-mode cache). If reading fails — corrupt/truncated cache file, an incompatibly serialized class after a Quarkus version change (ClassNotFoundException), or an I/O error — it wraps the failure in AppModelResolverException with this message. The cached model is deleted afterwards so a fresh resolution can occur on retry.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/util/BootstrapUtils.java:108

    public static Path serializeQuarkusModel(ApplicationModel model) throws IOException {
        final Path serializedModel = File.createTempFile("quarkus-model", ".dat").toPath();
        serializeAppModel(model, serializedModel);
        return serializedModel;
    }

    /**
     * @deprecated for removal since 3.31.0 in favor of ApplicationModelSerializer methods
     */
    @Deprecated(forRemoval = true)
    public static ApplicationModel deserializeQuarkusModel(Path modelPath) throws AppModelResolverException {
        if (Files.exists(modelPath)) {
            try (InputStream existing = Files.newInputStream(modelPath);
                    ObjectInputStream object = new ObjectInputStream(existing)) {
                ApplicationModel model = (ApplicationModel) object.readObject();
                IoUtils.recursiveDelete(modelPath);
                return model;
            } catch (IOException | ClassNotFoundException e) {
                throw new AppModelResolverException("Failed to deserialize quarkus model", e);
            }
        }
        throw new AppModelResolverException("Unable to locate quarkus model");
    }

    /**
     * Returns a location where a serialized {@link ApplicationModel} would be found for dev mode.
     *
     * @param projectBuildDir project build directory
     * @return file of a serialized application model for dev mode
     */
    public static Path resolveSerializedAppModelPath(Path projectBuildDir) {
        return getBootstrapBuildDir(projectBuildDir).resolve("dev-app-model.dat");
    }

    /**
     * Returns a location where a serialized {@link ApplicationModel} would be found for test mode.
     *

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the cached model file / run a clean build so the model is re-resolved from scratch
  2. Re-resolve the application model instead of relying on the cache
  3. If it recurs after version upgrades, ensure all Quarkus artifacts are the same version

Example fix

// after a Quarkus upgrade
mvn clean quarkus:dev
// or delete the stale cache manually
rm target/quarkus-bootstrap/app-model.dat
Defensive patterns

Strategy: fallback

Validate before calling

Path modelPath = BootstrapUtils.getSerializedModelLocation(buildDir);
boolean cacheUsable = Files.exists(modelPath)
    && Files.getLastModifiedTime(modelPath).toMillis() > lastCleanTime;
// if !cacheUsable, resolve the model fresh instead of deserializing

Try / catch

try {
    model = BootstrapUtils.deserializeQuarkusModel(modelPath);
} catch (AppModelResolverException e) {
    log.debugf("Cache unusable (%s), re-resolving", e.getMessage());
    model = resolver.resolveModel(workspace);
}

Prevention

When it happens

Trigger: Loading a dev-mode cached application model from a modelPath whose file was written by a different Quarkus version (readObject throws ClassNotFoundException) or is corrupt (IOException).

Common situations: Upgrading Quarkus (or a dependency of ApplicationModel classes) without cleaning target/; killed build leaving a truncated cache; copying build output between machines/JDKs.

Related errors


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