theonedev/onedev · error · org.apache.wicket.WicketRuntimeException

Null or empty component ID's are not allowed.

Error message

Null or empty component ID's are not allowed.

What it means

Component.setId() (package-private, invoked by constructors) throws WicketRuntimeException when the component id is null or the empty string, except for Page components. Every component needs a non-empty id because it is matched against the wicket:id in markup and used in path construction.

Source

Thrown at server-core/src/main/java/org/apache/wicket/Component.java:4383

				// thus will not throw an exception.
				markupStream.throwMarkupException("Expected close tag for " + openTag);
			}
		}
	}

	/**
	 * Sets the id of this component.
	 * 
	 * @param id
	 *            The non-null id of this component
	 */
	final Component setId(final String id)
	{
		if (!(this instanceof Page))
		{
			if (Strings.isEmpty(id))
			{
				throw new WicketRuntimeException("Null or empty component ID's are not allowed.");
			}
		}

		if ((id != null) && (id.indexOf(':') != -1 || id.indexOf('~') != -1))
		{
			throw new WicketRuntimeException("The component ID must not contain ':' or '~' chars.");
		}

		this.id = id;
		return this;
	}

	/**
	 * THIS IS A WICKET INTERNAL API. DO NOT USE IT.
	 * 
	 * Sets the parent of a component. Typically what you really want is parent.add(child).
	 * <p/>
	 * Note that calling setParent() and not parent.add() will connect the child to the parent, but

View on GitHub (pinned to d44925c47c)

Solutions

  1. Pass a literal non-empty id: new Label("myId", model).
  2. Validate/derive the id before constructing the component and fail early with a clear message.
  3. If the id is dynamic, ensure a fallback non-empty value is used.

Example fix

// before
String id = config.getId(); // may be ""
Label label = new Label(id, "v");
// after
String id = config.getId();
if (id == null || id.isEmpty()) { throw new IllegalArgumentException("missing component id"); }
Label label = new Label(id, "v");
Defensive patterns

Strategy: validation

Validate before calling

if (id == null || id.isEmpty()) throw new IllegalArgumentException("component id required");

Type guard

boolean validId = id != null && !id.trim().isEmpty();

Try / catch

try { new Label(id, model); } catch (WicketRuntimeException e) { throw new IllegalArgumentException("blank component id: " + e.getMessage()); }

Prevention

When it happens

Trigger: new Label(null, ...) or new Label("", ...); passing a variable holding null/empty as the component id; building ids dynamically from data that is blank.

Common situations: Ids derived from database values or i18n keys that come back empty; typos where the id argument was accidentally omitted; reflection-driven component factories feeding empty ids.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/91dab52bc0c7481b. Report an issue: GitHub.