apache/maven · error · XMLStreamException

Unable to parse element '{}', must be a floating point numbe

Error message

Unable to parse element '{}', must be a floating point number

What it means

Thrown by the Modello-generated StAX reader (template src/mdo/reader.vm) when a model XML field typed as double contains text Double.valueOf(String) cannot parse. In strict mode getDoubleValue wraps the NumberFormatException in a javax.xml.stream.XMLStreamException with the offending attribute/element name and parser location, aborting the document. Non-strict readers swallow it and return 0.

Source

Thrown at src/mdo/reader.vm:886

    /**
     * Method getDoubleValue.
     *
     * @param s a s object.
     * @param strict a strict object.
     * @param parser a parser object.
     * @param attribute a attribute object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return double
     */
    private double getDoubleValue(String s, String attribute, XMLStreamReader parser, boolean strict)
        throws XMLStreamException {
        if (s != null) {
            try {
                return Double.valueOf(s).doubleValue();
            } catch (NumberFormatException nfe) {
                if (strict) {
                    throw new XMLStreamException("Unable to parse element '" + attribute + "', must be a floating point number", parser.getLocation(), nfe);
                }
            }
        }
        return 0;
    } //-- double getDoubleValue(String, String, XMLStreamReader, boolean)

    /**
     * Method getFloatValue.
     *
     * @param s a s object.
     * @param strict a strict object.
     * @param parser a parser object.
     * @param attribute a attribute object.
     * @throws XMLStreamException XMLStreamException if
     * any.
     * @return float
     */
    private float getFloatValue(String s, String attribute, XMLStreamReader parser, boolean strict)

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Inspect the element named in the message and fix the value to standard Java double syntax (no thousands separators, dot as decimal point).
  2. Delete and re-fetch repository-derived files rather than editing them by hand.
  3. Read with strict=false if a default of 0 is acceptable for your use case.
  4. Fix the producing code to always format doubles with Locale.ROOT.

Example fix

<!-- before -->
<ratio>1,5</ratio>
<!-- after -->
<ratio>1.5</ratio>
Defensive patterns

Strategy: validation

Validate before calling

static boolean isParsableDouble(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatException | NullPointerException e) { return false; } }

Try / catch

try {
    reader.read(in, true);
} catch (XMLStreamException e) {
    if (e.getMessage().contains("must be a floating point number")) { /* repair value or reject input */ }
}

Prevention

When it happens

Trigger: Generated reader read()/read(..., strict=true) hits a double field holding an empty string, 'NaN ' with whitespace issues, '1,5' (locale comma), 'abc', or a hex string. Fails on first malformed value in the document.

Common situations: Model files generated on machines with comma-decimal locales; hand-edited XML where a numeric field was left empty (<delta/>); incomplete/corrupted downloads in the local repository; schema drift where a field became numeric in a newer model version.

Understand the failure class

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/fb3c17a0414f5002. Report an issue: GitHub.