{"record":{"id":"0ace638962561ec4","repo":"GoogleContainerTools/jib","slug":"failed-to-construct-entrypoint-because-no-files-we","errorCode":null,"errorMessage":"Failed to construct entrypoint because no files were added to the JavaContainerBuilder","messagePattern":"Failed to construct entrypoint because no files were added to the JavaContainerBuilder","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java","lineNumber":554,"sourceCode":"\n  /**\n   * Returns a new {@link JibContainerBuilder} using the parameters specified on the {@link\n   * JavaContainerBuilder}.\n   *\n   * @return a new {@link JibContainerBuilder} using the parameters specified on the {@link\n   *     JavaContainerBuilder}\n   * @throws IOException if building the {@link JibContainerBuilder} fails.\n   */\n  public JibContainerBuilder toContainerBuilder() throws IOException {\n    if (mainClass == null && !jvmFlags.isEmpty()) {\n      throw new IllegalStateException(\n          \"Failed to construct entrypoint on JavaContainerBuilder; \"\n              + \"jvmFlags were set, but mainClass is null. Specify the main class using \"\n              + \"JavaContainerBuilder#setMainClass(String), or consider using MainClassFinder to \"\n              + \"infer the main class.\");\n    }\n    if (classpathOrder.isEmpty()) {\n      throw new IllegalStateException(\n          \"Failed to construct entrypoint because no files were added to the JavaContainerBuilder\");\n    }\n\n    Map<LayerType, FileEntriesLayer.Builder> layerBuilders = new EnumMap<>(LayerType.class);\n\n    // Add classes to layer configuration\n    for (PathPredicatePair directory : addedClasses) {\n      addDirectoryContentsToLayer(\n          layerBuilders,\n          LayerType.CLASSES,\n          directory.path,\n          directory.predicate,\n          appRoot.resolve(classesDestination));\n    }\n\n    // Add resources to layer configuration\n    for (PathPredicatePair directory : addedResources) {\n      addDirectoryContentsToLayer(","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/api/JavaContainerBuilder.java#L536-L572","documentation":"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.","triggerScenarios":"Calling toContainerBuilder on a fresh JavaContainerBuilder without calling any addClasses/addDependencies/addResources/addToClasspath (or fromExplodedWar), then building.","commonSituations":"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.","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"],"exampleFix":"// before\nJibContainerBuilder jib = builder.toContainerBuilder();\n// after\nbuilder.addClasses(Paths.get(\"target/classes\"));\nJibContainerBuilder jib = builder.toContainerBuilder();","handlingStrategy":"validation","validationCode":"if (filesAdded.isEmpty()) throw new IllegalStateException(\"No files added; call addClasses/addDependencies before toContainerBuilder()\");","typeGuard":null,"tryCatchPattern":"try { JibContainerBuilder b = builder.toContainerBuilder(); } catch (IllegalStateException e) { if (e.getMessage().contains(\"no files were added\")) builder.addClasses(classesDir); }","preventionTips":["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"],"tags":["jib","configuration","empty-classpath"],"backgroundTag":"invalid-state-transition","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}