alibaba/spring-cloud-alibaba · error · ParseException
Invalid Month value: '{}'
Error message
Invalid Month value: '{}' What it means
Thrown in storeExpressionVals while parsing the MONTH field: when a token starts with a letter A-Z (so it is treated as a named month), getMonthNumber(sub) returns -1 because the three-letter abbreviation is not recognized (JAN..DEC). The parser then throws ParseException 'Invalid Month value: \'<sub>\''.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:338
}
protected int storeExpressionVals(final int pos, final String s, final int type)
throws ParseException {
int incr = 0;
int i = skipWhiteSpace(pos, s);
if (i >= s.length()) {
return i;
}
char c = s.charAt(i);
if ((c >= 'A') && (c <= 'Z') && (!s.equals("L")) && (!s.equals("LW")) && (!s.matches("^L-[0-9]*[W]?"))) {
String sub = s.substring(i, i + 3);
int sval = -1;
int eval = -1;
if (type == MONTH) {
sval = getMonthNumber(sub) + 1;
if (sval <= 0) {
throw new ParseException("Invalid Month value: '" + sub + "'", i);
}
if (s.length() > i + 3 && (s.charAt(i + 3) == '-')) {
i += 4;
sub = s.substring(i, i + 3);
eval = getMonthNumber(sub) + 1;
Assert.isTrue(eval > 0, "Invalid Month value: '" + sub + "'");
}
}
else if (type == DAY_OF_WEEK) {
sval = getDayOfWeekNumber(sub);
if (sval < 0) {
throw new ParseException("Invalid Day-of-Week value: '"
+ sub + "'", i);
}
if (s.length() > i + 3) {
c = s.charAt(i + 3);
if (c == '-') {
i += 4;View on GitHub (pinned to 115d590110)
Solutions
- Use a valid three-letter English month abbreviation (JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC) or a numeric value 1-12.
- Double-check the spelling; the parser only accepts the exact abbreviations in monthMap.
- Validate at config load.
Example fix
# before (typo) 0 0 0 * JNA ? # after 0 0 0 * JAN ?
Defensive patterns
Strategy: try-catch
Validate before calling
static String validateCron(String cron) throws ParseException {
new com.alibaba.cloud.scheduling.schedulerx.util.CronExpression(cron);
return cron;
} Type guard
static final java.util.Set<String> MONTHS = java.util.Set.of(
"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
static boolean validMonthToken(String t) {
return MONTHS.contains(t) || t.matches("\\d+(/\\d+)?(-\\d+)?");
} Try / catch
try {
new CronExpression(cron);
} catch (ParseException e) {
// "Invalid Month value: 'JNA'"
log.error("Bad month in cron '{}': {}", cron, e.getMessage());
} Prevention
- Prefer numeric months (1-12) to avoid spelling mistakes.
- Trial-parse crons during validation to surface bad month tokens early.
When it happens
Trigger: A month field with an unrecognised 3-letter token, e.g. '0 0 0 * ABC ?' or a typo like '0 0 0 * JUN ?' (note: only JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC are valid — 'ABC' is not). The check at CronExpression.java:343-345 fires when sval <= 0.
Common situations: Typo in a month abbreviation; using a full month name 'JANUARY' instead of 'JAN'; locale/uppercase issues where the value is not uppercased (the parser uppercases the whole expression, so this is usually a genuine typo).
Related errors
- Support for specifying 'L' and 'LW' with other days of the m
- Support for specifying 'L' with other days of the week is no
- Support for specifying multiple "nth" days is not implemente
- Unexpected end of expression.
- Support for specifying both a day-of-week AND a day-of-month
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/4fe908a273c6ebbe.
Report an issue: GitHub.