GoogleContainerTools/jib · error · IOException

Obtaining project build output files failed; make sure you h

Error message

Obtaining project build output files failed; make sure you have ${packaged|compiled} your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean ${package|compile} jib:build"?)

What it means

Jib could not find any project build output files (jars/classes) to layer into the image because the project was compiled with 'clean' but never packaged or compiled. Maven goals like 'jib:build' do not themselves trigger the lifecycle phases that produce artifacts, so Jib has nothing to containerize and throws this IOException from MavenProjectProperties.createJibContainerBuilder.

Source

Thrown at jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/MavenProjectProperties.java:318

        default:
          throw new IllegalStateException("unknown containerizing mode: " + containerizingMode);
      }

      // Classify and add dependencies
      Map<LayerType, List<Path>> classifiedDependencies =
          classifyDependencies(project.getArtifacts(), getProjectDependencies());

      javaContainerBuilder.addDependencies(
          Preconditions.checkNotNull(classifiedDependencies.get(LayerType.DEPENDENCIES)));
      javaContainerBuilder.addSnapshotDependencies(
          Preconditions.checkNotNull(classifiedDependencies.get(LayerType.SNAPSHOT_DEPENDENCIES)));
      javaContainerBuilder.addProjectDependencies(
          Preconditions.checkNotNull(classifiedDependencies.get(LayerType.PROJECT_DEPENDENCIES)));
      return javaContainerBuilder.toContainerBuilder();

    } catch (IOException ex) {
      throw new IOException(
          "Obtaining project build output files failed; make sure you have "
              + (isPackageErrorMessage(containerizingMode) ? "packaged" : "compiled")
              + " your project "
              + "before trying to build the image. (Did you accidentally run \"mvn clean "
              + "jib:build\" instead of \"mvn clean "
              + (isPackageErrorMessage(containerizingMode) ? "package" : "compile")
              + " jib:build\"?)",
          ex);
    }
  }

  @VisibleForTesting
  Set<Artifact> getProjectDependencies() {
    return session.getProjects().stream()
        .map(MavenProject::getArtifact)
        .filter(artifact -> !artifact.equals(project.getArtifact()))
        .filter(artifact -> artifact.getFile() != null)
        .collect(Collectors.toSet());

View on GitHub (pinned to fb949e2676)

Solutions

  1. Run the full lifecycle before Jib: 'mvn clean package jib:build' (or 'mvn clean compile jib:build' if using containerizingMode=exploded).
  2. Verify your containerizingMode setting (<containerizingMode> in pom.xml) matches the phase you ran — packaged requires package, exploded requires compile.
  3. Check CI pipelines and wrapper scripts for the accidental 'mvn clean jib:build' pattern and add the missing phase.
  4. Bind jib to the package phase via an <execution> so the artifact always exists when it runs.

Example fix

// before
mvn clean jib:build

// after
mvn clean package jib:build
Defensive patterns

Strategy: validation

Validate before calling

// Check target output exists before invoking jib goals
if (!java.nio.file.Files.exists(java.nio.file.Path.of("target", "classes"))
    && !java.nio.file.Files.exists(java.nio.file.Path.of("target", "*.jar"))) {
  throw new IllegalStateException("Run 'mvn package' (or 'compile' for exploded mode) before jib:build");
}

Try / catch

try {
  // mvn clean package jib:build
} catch (IOException e) {
  if (e.getMessage().contains("Obtaining project build output files failed")) {
    // rerun with package phase: mvn clean package jib:build
  }
  throw e;
}

Prevention

When it happens

Trigger: Running 'mvn clean jib:build' or 'mvn clean jib:dockerBuild' without a preceding 'package' (or 'compile' when containerizingMode=packaged... actually processed) phase; running jib goals directly on a freshly cleaned workspace; building from an IDE goal that skips lifecycle phases.

Common situations: Developer assumes the jib plugin goal runs the package phase automatically; CI scripts calling 'mvn clean jib:build'; switching containerizingMode between 'packaged' and 'exploded' so the required phase changes; typo in a wrapper script omitting 'package'.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/b28951d5792ae06c. Report an issue: GitHub.