JetBrains/intellij-community · error · CodeGenerationException

Error loading nested form:

Error message

Error loading nested form: 

What it means

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.

Source

Thrown at java/compiler/forms-compiler/src/com/intellij/uiDesigner/compiler/Utils.java:222

    HashSet<String> usedFormNames = new HashSet<>();
    if (targetForm != null) {
      usedFormNames.add(targetForm);
    }
    validateNestedFormLoop(usedFormNames, formName, nestedFormLoader);
  }

  private static void validateNestedFormLoop(final Set<String> usedFormNames, final String formName, final NestedFormLoader nestedFormLoader)
    throws CodeGenerationException, RecursiveFormNestingException {
    if (usedFormNames.contains(formName)) {
      throw new RecursiveFormNestingException();
    }
    usedFormNames.add(formName);
    final LwRootContainer rootContainer;
    try {
      rootContainer = nestedFormLoader.loadForm(formName);
    }
    catch (Exception e) {
      throw new CodeGenerationException(null, "Error loading nested form: " + e.getMessage(), e);
    }
    final Set<String> thisFormNestedForms = new HashSet<>();
    final CodeGenerationException[] validateExceptions = new CodeGenerationException[1];
    final RecursiveFormNestingException[] recursiveNestingExceptions = new RecursiveFormNestingException[1];
    rootContainer.accept(new ComponentVisitor() {
      @Override
      public boolean visit(final IComponent component) {
        if (component instanceof LwNestedForm) {
          LwNestedForm nestedForm = (LwNestedForm)component;
          if (!thisFormNestedForms.contains(nestedForm.getFormFileName())) {
            thisFormNestedForms.add(nestedForm.getFormFileName());
            try {
              validateNestedFormLoop(usedFormNames, nestedForm.getFormFileName(), nestedFormLoader);
            }
            catch (RecursiveFormNestingException e) {
              recursiveNestingExceptions[0] = e;
              return false;
            }

View on GitHub (pinned to be881553f2)

Solutions

  1. Read the chained message after 'Error loading nested form:' — it names the real cause; fix that (missing file, parse error, bad binding) first.
  2. 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).
  3. If the nested form was renamed or moved, update the parent form's nested-form component to point to the new form file.
  4. Rebuild the class-to-bind of the nested form so it can be loaded during validation.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before compiling, confirm each nested form file loads standalone
LwRootContainer nested = Utils.loadFormXml(nestedFormVirtualFile.getInputStream()); // if this fails, fix here first

Try / catch

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 */ } }

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/a3d4c702ade14288. Report an issue: GitHub.