jeecgboot/JeecgBoot · error · ParseException
Unexpected character: {c}
Error message
Unexpected character: {c} What it means
The terminal else of storeExpressionVals: the current character c matched none of the recognized branches (not A-Z alpha, not '?', not '*' or '/', not 'L', not a digit 0-9). Any unrecognised symbol - punctuation, lowercase, special chars - lands here. It is the fallback for truly unexpected characters at a position where a value was expected.
Source
Thrown at jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java:720
}
return i;
} else if (c >= '0' && c <= '9') {
int val = Integer.parseInt(String.valueOf(c));
i++;
if (i >= s.length()) {
addToSet(val, -1, -1, type);
} else {
c = s.charAt(i);
if (c >= '0' && c <= '9') {
ValueSet vs = getValue(val, s, i);
val = vs.value;
i = vs.pos;
}
i = checkNext(i, s, val, type);
return i;
}
} else {
throw new ParseException("Unexpected character: " + c, i);
}
return i;
}
private void checkIncrementRange(int incr, int type, int idxPos) throws ParseException {
if (incr > 59 && (type == SECOND || type == MINUTE)) {
throw new ParseException("Increment >= 60 : " + incr, idxPos);
} else if (incr > 23 && (type == HOUR)) {
throw new ParseException("Increment >= 24 : " + incr, idxPos);
} else if (incr > 31 && (type == DAY_OF_MONTH)) {
throw new ParseException("Increment >= 31 : " + incr, idxPos);
} else if (incr > 7 && (type == DAY_OF_WEEK)) {
throw new ParseException("Increment >= 7 : " + incr, idxPos);
} else if (incr > 12 && (type == MONTH)) {
throw new ParseException("Increment >= 12 : " + incr, idxPos);
}
}View on GitHub (pinned to 96fb33f5ec)
Solutions
- Inspect the character at the reported position and replace it with a valid token (digit, '*', '?', '/', '-', 'L', or 'W' where supported).
- Use ',' only between list elements inside a field, not at the start/end.
- Uppercase all letter modifiers ('L', 'W'); the parser only enters the alpha branch for A-Z.
- Strip non-cron characters from pasted expressions before parsing.
Example fix
// before - stray '.' in day-of-month String cron = "0 0 0 5.5 * ?"; // Unexpected character: . // after - valid list or single value String cron = "0 0 0 5,15 * ?";
Defensive patterns
Strategy: validation
Validate before calling
// Whitelist the allowed character set for the whole expression before parsing.
private static final java.util.regex.Pattern CRON_CHARSET =
java.util.regex.Pattern.compile("^[0-9*?/\\-,LW# A-Za-z]+$");
public static String validateCharset(String expr) {
if (expr == null || !CRON_CHARSET.matcher(expr).matches()) {
return "expression contains characters outside the allowed cron charset: " + expr;
}
return null;
} Type guard
public static boolean usesAllowedCronCharset(String expr) {
return expr != null && expr.matches("[0-9*?/\\-,LW# A-Za-z]+");
} Try / catch
try {
new CronExpression(expr);
} catch (ParseException e) {
if (e.getMessage().startsWith("Unexpected character")) {
return "Remove the symbol at the reported position; only 0-9 * ? / - , L W # and letters are allowed. " + e.getMessage();
}
throw e;
} Prevention
- Sanitize pasted cron strings against the allowed charset before parsing.
- Uppercase all letter modifiers ('L', 'W'); lowercase is rejected.
- Reject decimal commas/points and stray punctuation in the input UI.
When it happens
Trigger: Characters like '@', '#', '!', '.', ',', lowercase letters, or a stray symbol in a value position: '0 0 0 ,5 * * ?' (leading comma), '0 0 0 #5 * * ?', '0 0 0 5.5 * * ?', or lowercase 'l' instead of 'L'.
Common situations: Locale-specific separators (e.g. decimal comma), stray punctuation from copy/paste, lowercase 'l'/'w' that should be uppercase, or a typo inserting a symbol.
Related errors
- Illegal cron expression format ({e})
- Invalid Month value: '{sub}'
- Invalid Day-of-Week value: '{sub}'
- A numeric value between 1 and 5 must follow the '#' option
- Illegal characters for this position: '{sub}'
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/d32bc5e94a442e2c.
Report an issue: GitHub.