GoogleContainerTools/jib · error · IllegalStateException
Failed to construct entrypoint because no files were added t
Error message
Failed to construct entrypoint because no files were added to the JavaContainerBuilder
What it means
toContainerBuilder builds the entrypoint around the files added to the JavaContainerBuilder. If no classes/resources/dependencies were added (classpathOrder empty), there is nothing to put on the java classpath, so it throws IllegalStateException. Ensures a Java image isn't produced with an empty application.
Source
Thrown at jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java:554
/**
* Returns a new {@link JibContainerBuilder} using the parameters specified on the {@link
* JavaContainerBuilder}.
*
* @return a new {@link JibContainerBuilder} using the parameters specified on the {@link
* JavaContainerBuilder}
* @throws IOException if building the {@link JibContainerBuilder} fails.
*/
public JibContainerBuilder toContainerBuilder() throws IOException {
if (mainClass == null && !jvmFlags.isEmpty()) {
throw new IllegalStateException(
"Failed to construct entrypoint on JavaContainerBuilder; "
+ "jvmFlags were set, but mainClass is null. Specify the main class using "
+ "JavaContainerBuilder#setMainClass(String), or consider using MainClassFinder to "
+ "infer the main class.");
}
if (classpathOrder.isEmpty()) {
throw new IllegalStateException(
"Failed to construct entrypoint because no files were added to the JavaContainerBuilder");
}
Map<LayerType, FileEntriesLayer.Builder> layerBuilders = new EnumMap<>(LayerType.class);
// Add classes to layer configuration
for (PathPredicatePair directory : addedClasses) {
addDirectoryContentsToLayer(
layerBuilders,
LayerType.CLASSES,
directory.path,
directory.predicate,
appRoot.resolve(classesDestination));
}
// Add resources to layer configuration
for (PathPredicatePair directory : addedResources) {
addDirectoryContentsToLayer(View on GitHub (pinned to fb949e2676)
Solutions
- Add application content first: call addClasses (and addResources/addDependencies as needed) before toContainerBuilder
- Verify your exploded WAR/source directory actually contains files before wiring the builder
- Check control flow isn't skipping all add* calls when collections are empty
- Catch IllegalStateException and report that no application files were configured
Example fix
// before
JibContainerBuilder jib = builder.toContainerBuilder();
// after
builder.addClasses(Paths.get("target/classes"));
JibContainerBuilder jib = builder.toContainerBuilder(); Defensive patterns
Strategy: validation
Validate before calling
if (filesAdded.isEmpty()) throw new IllegalStateException("No files added; call addClasses/addDependencies before toContainerBuilder()"); Try / catch
try { JibContainerBuilder b = builder.toContainerBuilder(); } catch (IllegalStateException e) { if (e.getMessage().contains("no files were added")) builder.addClasses(classesDir); } Prevention
- Call addClasses (and addResources/addDependencies) before toContainerBuilder
- Verify the exploded WAR/source directory contains files
- Add a test that builds the container with your standard configuration
When it happens
Trigger: Calling toContainerBuilder on a fresh JavaContainerBuilder without calling any addClasses/addDependencies/addResources/addToClasspath (or fromExplodedWar), then building.
Common situations: Conditional code paths that skip adding files when lists are empty; forgetting to call addClasses after setMainClass; fromExplodedWar pointed at an empty/incorrect exploded WAR layout.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Failed to construct entrypoint on JavaContainerBuilder; jvmF
- <field1> and <field2> are required but not set
- <field1>, <field2>, ... and <fieldN> are required but not se
- container.appRoot is not an absolute Unix-style path: ${inva
- invalid value for containerizingMode: ${invalidContainerizin
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/0ace638962561ec4.
Report an issue: GitHub.