{"record":{"id":"a3d4c702ade14288","repo":"JetBrains/intellij-community","slug":"error-loading-nested-form","errorCode":null,"errorMessage":"Error loading nested form: ","messagePattern":"Error loading nested form: ","errorType":"validation","errorClass":"CodeGenerationException","httpStatus":null,"severity":"error","filePath":"java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/Utils.java","lineNumber":222,"sourceCode":"    HashSet<String> usedFormNames = new HashSet<>();\n    if (targetForm != null) {\n      usedFormNames.add(targetForm);\n    }\n    validateNestedFormLoop(usedFormNames, formName, nestedFormLoader);\n  }\n\n  private static void validateNestedFormLoop(final Set<String> usedFormNames, final String formName, final NestedFormLoader nestedFormLoader)\n    throws CodeGenerationException, RecursiveFormNestingException {\n    if (usedFormNames.contains(formName)) {\n      throw new RecursiveFormNestingException();\n    }\n    usedFormNames.add(formName);\n    final LwRootContainer rootContainer;\n    try {\n      rootContainer = nestedFormLoader.loadForm(formName);\n    }\n    catch (Exception e) {\n      throw new CodeGenerationException(null, \"Error loading nested form: \" + e.getMessage(), e);\n    }\n    final Set<String> thisFormNestedForms = new HashSet<>();\n    final CodeGenerationException[] validateExceptions = new CodeGenerationException[1];\n    final RecursiveFormNestingException[] recursiveNestingExceptions = new RecursiveFormNestingException[1];\n    rootContainer.accept(new ComponentVisitor() {\n      @Override\n      public boolean visit(final IComponent component) {\n        if (component instanceof LwNestedForm) {\n          LwNestedForm nestedForm = (LwNestedForm)component;\n          if (!thisFormNestedForms.contains(nestedForm.getFormFileName())) {\n            thisFormNestedForms.add(nestedForm.getFormFileName());\n            try {\n              validateNestedFormLoop(usedFormNames, nestedForm.getFormFileName(), nestedFormLoader);\n            }\n            catch (RecursiveFormNestingException e) {\n              recursiveNestingExceptions[0] = e;\n              return false;\n            }","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/Utils.java#L204-L240","documentation":"Thrown by Utils.validateNestedFormLoop when NestedFormLoader.loadForm(formName) raises any Exception while recursively validating a form that embeds other forms. Nested-form validation must load each referenced form to detect recursive nesting; a failure to load any nested form (parse error, missing file, I/O problem) is wrapped into a CodeGenerationException prefixed with 'Error loading nested form:' followed by the underlying message.","triggerScenarios":"A .form file contains a nested-form component whose form file cannot be parsed or located: the nested .form has malformed XML, references a class-to-bind that fails to load, or the form name does not map to a resource the NestedFormLoader can resolve. The original exception's message is chained into this one.","commonSituations":"Moving/renaming a nested .form file without updating the reference in the parent form; nested form XML edited by hand and no longer valid; nested form bound to a class that fails to compile; resource-path mismatches when forms are loaded from jars in build scripts (GUI Designer form instrumentation in Ant/Gradle builds).","solutions":["Read the chained message after 'Error loading nested form:' — it names the real cause; fix that (missing file, parse error, bad binding) first.","Verify the nested form file exists at the path referenced by the parent form component and is valid form XML (open it in the GUI designer).","If the nested form was renamed or moved, update the parent form's nested-form component to point to the new form file.","Rebuild the class-to-bind of the nested form so it can be loaded during validation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before compiling, confirm each nested form file loads standalone\nLwRootContainer nested = Utils.loadFormXml(nestedFormVirtualFile.getInputStream()); // if this fails, fix here first","typeGuard":null,"tryCatchPattern":"try { Utils.validateNestedFormLoop(...); } catch (CodeGenerationException e) { if (e.getMessage().startsWith(\"Error loading nested form\")) { String realCause = e.getMessage().substring(\"Error loading nested form: \".length()); /* fix the nested .form itself */ } }","preventionTips":["Keep nested form references relative to the project and update them when forms move.","Validate nested forms standalone before embedding them.","Always read the chained cause message; the real failure is in the nested form, not the parent."],"tags":["gui-designer","forms-compiler","nested-forms","resource-loading","chained-exception"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}