GoogleContainerTools/jib · error · IllegalArgumentException
manifestTemplateClass + " cannot be instantiated"
Error message
manifestTemplateClass + " cannot be instantiated"
What it means
ImageToJsonTranslator.getManifestTemplate() instantiates the manifest template class via reflection. If the class has no accessible no-arg constructor or cannot be instantiated, the reflective exceptions are wrapped in an IllegalArgumentException naming the class.
Source
Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/image/json/ImageToJsonTranslator.java:214
// Adds the container configuration reference.
DescriptorDigest containerConfigurationDigest =
containerConfigurationBlobDescriptor.getDigest();
long containerConfigurationSize = containerConfigurationBlobDescriptor.getSize();
template.setContainerConfiguration(containerConfigurationSize, containerConfigurationDigest);
// Adds the layers.
for (Layer layer : image.getLayers()) {
template.addLayer(
layer.getBlobDescriptor().getSize(), layer.getBlobDescriptor().getDigest());
}
return template;
} catch (InstantiationException
| IllegalAccessException
| NoSuchMethodException
| InvocationTargetException ex) {
throw new IllegalArgumentException(manifestTemplateClass + " cannot be instantiated", ex);
}
}
}
View on GitHub (pinned to fb949e2676)
Solutions
- Ensure the manifest template class is public, concrete, and has a public no-arg constructor
- Use a built-in template such as V22ManifestTemplate or OCIManifestTemplate
- Check the wrapped cause (ex.getCause()) for the underlying reflection error
Example fix
// before Image.builder(MyManifestTemplate.class); // abstract / no no-arg ctor // after Image.builder(V22ManifestTemplate.class); // public class with implicit no-arg constructor
Defensive patterns
Strategy: validation
Validate before calling
Class<?> c = manifestTemplateClass; if (c.isInterface() || Modifier.isAbstract(c.getModifiers()) || c.getConstructors().length == 0) throw new IllegalArgumentException(c + " needs a public no-arg constructor");
Try / catch
try { Image.builder(clazz); } catch (IllegalArgumentException e) { inspect e.getCause() (InstantiationException/IllegalAccessException/etc.); } Prevention
- Manifest template classes must be public, concrete, with a no-arg constructor
- Prefer built-in templates (V22ManifestTemplate, OCIManifestTemplate)
- Always inspect the wrapped cause for the root reflection error
When it happens
Trigger: Passing a manifestTemplateClass to Image.builder(...) or ImageToJsonTranslator whose class lacks a public no-arg constructor, is abstract, or whose constructor throws; class initialization failure on load.
Common situations: Supplying a custom BuildableManifestTemplate implementation that doesn't follow the no-arg constructor convention; passing an abstract class or interface; classpath/version conflicts where the class's static init fails.
Related errors
- Dependency required by the JAR (as specified in `Class-Path`
- `Main-Class:` attribute for an application main class not de
- `Main-Class:` attribute for an application main class not de
- Invalid container configuration in Docker V2.2/OCI manifest:
- Manifest(s) missing
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/3ba242287ad07828.
Report an issue: GitHub.