Skip to content

Fix NullPointerException in CmsADEConfigData.hasFormatters() for resource types without a schema - #846

Open
gallardo wants to merge 1 commit into
alkacon:masterfrom
gallardo:fix/ade-has-formatters-npe-upstream
Open

Fix NullPointerException in CmsADEConfigData.hasFormatters() for resource types without a schema#846
gallardo wants to merge 1 commit into
alkacon:masterfrom
gallardo:fix/ade-has-formatters-npe-upstream

Conversation

@gallardo

@gallardo gallardo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem

When a resource type referenced by a sitemap configuration is defined without a schema configuration parameter, opening the container page editor logs this error on every add-dialog build:

ERROR ... CmsAddDialogTypeHelper: Cannot invoke
"org.opencms.xml.CmsXmlContentDefinition.getContentHandler()" because "def" is null
  at org.opencms.ade.configuration.CmsADEConfigData.hasFormatters(CmsADEConfigData.java)
  at org.opencms.ade.containerpage.CmsContainerpageService$2.checkEnabled(...)

CmsXmlContentDefinition.getContentDefinitionForType() intentionally returns null in that case, but hasFormatters() dereferences the result unconditionally. The resulting NullPointerException is swallowed per type by CmsAddDialogTypeHelper, which also means the formatter check is silently skipped for the affected type (it shows up in the add menu even without any matching formatter).

Fix

Treat a missing content definition as "no formatters" (return false) and log a warning that names the offending type, so the underlying misconfiguration is diagnosable from the log instead of surfacing as an NPE.

The sibling method getTypesWithModifiableFormatters() in the same class already handles the null return from getContentDefinitionForType() this way.

Verification

  • ./gradlew compileJava passes.
  • Reproduced and verified against a 21.0-based installation where a type without a schema param was referenced by a sitemap configuration.

🤖 Generated with Claude Code

…source types without a schema.

CmsXmlContentDefinition.getContentDefinitionForType() returns null when a
resource type has no "schema" configuration parameter. hasFormatters()
dereferenced the result unconditionally, causing a NullPointerException
(logged by CmsAddDialogTypeHelper on every container page editor load)
whenever such a type is referenced by a sitemap configuration.

Treat a missing content definition as "no formatters" and log a warning
naming the offending type, so the misconfiguration is visible instead of
surfacing as an NPE.

Co-Authored-By: Claude Code, Fable 5 <noreply@anthropic.com>
@gallardo

gallardo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Don't merge yet. I'm still trying to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant