Skip to content

Troubleshooting

Damian Malczewski edited this page Sep 10, 2026 · 1 revision

Troubleshooting

Schema errors are raised while loading, before anything is written. Every one of them is a SchemaException, and every message is prefixed with the file name:

com.example.dto.Person.json: property "age": unsupported format "short" for type "integer" (allowed: int, long)

A load reports every problem it finds rather than stopping at the first, so a batch of broken schemas comes back as one listing:

3 schema errors:
  - com.example.dto.Address.json: missing "title"
  - com.example.dto.Order.json: property "total": default must be a number
  - com.example.dto.Person.json: property "age": unsupported format "short" for type "integer" (allowed: int, long)

File and header errors

  • not valid JSON (...) - the file is not parseable JSON.
  • missing "$modelmaker" - the version key is absent. Add "$modelmaker": "v1.0".
  • unsupported "$modelmaker": "X" (only "v1.0" is supported) - unknown schema version.
  • missing "title" - no title key.
  • "title" must be a fully-qualified class name, e.g. "com.example.dto.Foo" - title has no package part.
  • file must be named "<title>.json" to match its title - file name and title disagree. Rename the file.
  • top-level "type" must be "object" - the top-level type is missing or is not "object".
  • type "X": missing "properties" object - no properties on the type, or on an inline nested object.
  • <file>: unsupported file extension "x" - a file the loader does not handle was passed in.

Property errors

  • property "x": needs "type" or "$ref" - the property object has neither key.
  • property "x": unsupported type "t" (allowed: string, bytes, integer, number, boolean, object, array, $ref) - unknown type value.
  • property "x": unsupported format "f" for type "integer" (allowed: int, long) - bad format on an integer.
  • property "x": unsupported format "f" for type "number" (allowed: double, float) - bad format on a number.
  • property "x": array needs "items" - an array without an element schema.
  • property "x": nested arrays are not supported - items is itself an array.
  • nested object "title" must be a plain class name, not "X" - an inline object's title contains a ..

Naming errors

  • type "T": property "k" must be camelCase, snake_case, or UpperCamelCase, optionally prefixed with underscores - the key form is not accepted, see Property Naming.
  • type "T": properties "a" and "b" both map to the field name "f" - two keys normalize to the same Java field.

Default value errors

  • property "x": default must be a string - and the an integer / a number / a boolean / an array variants: the default's JSON type does not match the property type.
  • property "x": default is not supported for "bytes" - bytes has no default support.
  • property "x": array default is only supported for scalar items - a default on an array of objects or $refs.
  • property "x": default is not supported for object / $ref properties - a default on an object-typed property.

Reference errors

  • Customer.shippingAddress: $ref "X" does not match any schema title or nested type - the target schema is missing from the source tree, the title is spelled differently, or the nested-type name is wrong. A JDK target must start with java. or javax..

Feature block errors

  • "features" must be an object - features is a scalar or an array.
  • unknown "features" entry "x" - only jackson, validation, openApi, withers and preferPrimitives are accepted.
  • "features.jackson" must be an object, e.g. { "enabled": true } - a bare boolean was used.
  • unknown "features.jackson" entry "x" - only enabled, annotateFields and annotateGetters, or enabled alone for withers / preferPrimitives.
  • "features.jackson.enabled" must be a boolean - a non-boolean value.

cannot find symbol: class JsonProperty (or NotNull, Schema, NullMarked)

The feature is on but its library is missing from the compile classpath. Add the dependency, see Getting Started. For NullMarked specifically: the plugin only contributes org.jspecify:jspecify when the java plugin is applied - check that it is.

Nothing is generated

  • Schemas must be under src/main/model with a .json extension. The task logs No model schemas found in ....
  • generateModelJava runs as part of compilation; running only ./gradlew test on an up-to-date build may show it as UP-TO-DATE rather than re-running.

No Kotlin extensions appear

Both modelmaker { kotlin { enabled = true } } and the org.jetbrains.kotlin.jvm plugin are required. With either missing, generateModelKotlin deletes its output directory instead of writing to it - which is also why previously generated .kt files disappear after turning Kotlin off. See Kotlin Extensions.

My edits to a generated file are gone

Expected: the output directory is wiped and rebuilt on every run. Change the schema or the feature flags instead.

NullPointerException: id is required

Builder.build() enforces that every required property was set. Either set it, or drop it from the schema's required array. Note that this is a construction check, not bean validation - see Validation.

Every constraint violation is reported twice

annotateFields and annotateGetters are both on for validation, so each constraint is emitted at both sites. Pick one, see Feature Configuration.

A required property deserializes to null instead of failing

Jackson binds through the constructor and does not enforce requiredness - or any other constraint. Turn on validation and make sure something actually runs a Validator: a framework at its own boundary (Spring Boot's @Valid @RequestBody, for instance), or your own code. See Validation.

Spotless keeps reformatting generated sources

With src.enabled = true the output lives in the project tree. Exclude it:

spotless {
    java {
        targetExclude("build/**", "src/main/model/java/**")
    }
}

Still stuck

Check the FAQ, then open an issue at damianmalczewski/modelmaker/issues with the schema and the message.

Clone this wiki locally