GoogleContainerTools/jib · error · MojoExecutionException

<message from InvalidImageReferenceException via HelpfulSugg

Error message

<message from InvalidImageReferenceException via HelpfulSuggestions.forInvalidImageReference>

What it means

jib-maven-plugin throws this when the <from><image>, <to><image>, or related image reference string cannot be parsed as a valid registry/repository/tag reference. HelpfulSuggestions.forInvalidImageReference includes the invalid reference and suggests the expected format (e.g. registry/project/image:tag). It surfaces as a MojoExecutionException from BuildImageMojo.execute.

Source

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

          "<container><creationTime> should be an ISO 8601 date-time (see "
              + "DateTimeFormatter.ISO_DATE_TIME) or a special keyword (\"EPOCH\", "
              + "\"USE_CURRENT_TIMESTAMP\"): "
              + ex.getInvalidCreationTime(),
          ex);

    } catch (JibPluginExtensionException ex) {
      String extensionName = ex.getExtensionClass().getName();
      throw new MojoExecutionException(
          "error running extension '" + extensionName + "': " + ex.getMessage(), ex);

    } catch (IncompatibleBaseImageJavaVersionException ex) {
      throw new MojoExecutionException(
          HelpfulSuggestions.forIncompatibleBaseImageJavaVersionForMaven(
              ex.getBaseImageMajorJavaVersion(), ex.getProjectMajorJavaVersion()),
          ex);

    } catch (InvalidImageReferenceException ex) {
      throw new MojoExecutionException(
          HelpfulSuggestions.forInvalidImageReference(ex.getInvalidReference()), ex);

    } catch (IOException
        | CacheDirectoryCreationException
        | MainClassInferenceException
        | InvalidGlobalConfigException ex) {
      throw new MojoExecutionException(ex.getMessage(), ex);

    } catch (BuildStepsExecutionException ex) {
      throw new MojoExecutionException(ex.getMessage(), ex.getCause());

    } catch (ExtraDirectoryNotFoundException ex) {
      throw new MojoExecutionException(
          "<extraDirectories><paths> contain \"from\" directory that doesn't exist locally: "
              + ex.getPath(),
          ex);
    } finally {
      tempDirectoryProvider.close();

View on GitHub (pinned to fb949e2676)

Solutions

  1. Inspect the invalid reference printed in the message and fix its format in <from><image> or <to><image>.
  2. Use the full form <registry>/<repository>:<tag>, e.g. 'gcr.io/my-project/my-app:1.0'.
  3. If the value comes from a property or env substitution, verify it expands to a non-empty, well-formed string.

Example fix

<!-- before -->
<to><image>My App Image</image></to>
<!-- after -->
<to><image>gcr.io/my-project/my-app:1.0</image></to>
Defensive patterns

Strategy: validation

Validate before calling

String ref = "gcr.io/my-project/my-app:1.0";
if (!ref.matches("[a-z0-9]+((\.|/|:|-|_)[a-z0-9]+)*(:[\w.-]+)?(@sha256:[a-f0-9]{64})?")) {
  throw new IllegalArgumentException("invalid image reference: " + ref);
}

Try / catch

try { ... } catch (MojoExecutionException e) { if (e.getCause() instanceof InvalidImageReferenceException) { /* correct the reference in pom */ } throw e; }

Prevention

When it happens

Trigger: Running 'mvn jib:build' with an image reference that violates Docker registry naming rules: empty, illegal characters, uppercase in repository, malformed tag/digest, or a bare name with spaces (InvalidImageReferenceException).

Common situations: Typo in the image name in pom.xml; using an environment placeholder that expands empty; adding a tag with invalid characters like ':' or '#'; forgetting the registry prefix when needed.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


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