xuxueli/xxl-job · error · ParseException
'/' must be followed by an integer.
Error message
'/' must be followed by an integer.
What it means
This error occurs when the parser encounters a '/' character that is not followed by a valid increment integer — specifically when '/' is at the end of the field, or followed by a space/tab. In cron syntax, '/' specifies a step/increment value (e.g., '*/5'), and it must be followed by a number.
Source
Thrown at xxl-job-admin/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java:643
if (!daysOfMonth.isEmpty() && daysOfMonth.last() == NO_SPEC_INT) {
throw new ParseException(
"'?' can only be specified for Day-of-Month -OR- Day-of-Week.",
i);
}
}
addToSet(NO_SPEC_INT, -1, 0, type);
return i;
}
if (c == '*' || c == '/') {
if (c == '*' && (i + 1) >= s.length()) {
addToSet(ALL_SPEC_INT, -1, incr, type);
return i + 1;
} else if (c == '/'
&& ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
.charAt(i + 1) == '\t')) {
throw new ParseException("'/' must be followed by an integer.", i);
} else if (c == '*') {
i++;
}
c = s.charAt(i);
if (c == '/') { // is an increment specified?
i++;
if (i >= s.length()) {
throw new ParseException("Unexpected end of string.", i);
}
incr = getNumericValue(s, i);
i++;
if (incr > 10) {
i++;
}
checkIncrementRange(incr, type, i);
} else {View on GitHub (pinned to e74c784f68)
Solutions
- Add a valid integer after the '/' (e.g., '*/5' instead of '*/').
- Remove the '/' if no increment is intended (use '*' alone).
- Validate the cron string with a regex or cron validator before passing it to the constructor.
Example fix
// before "*/ * * * * ?" // after "*/5 * * * * ?"
Defensive patterns
Strategy: validation
Validate before calling
// Reject fields where '/' is not followed by a digit
for (String field : cron.trim().split("\\s+")) {
int slash = field.indexOf('/');
if (slash != -1 && (slash + 1 >= field.length() || !Character.isDigit(field.charAt(slash + 1)))) {
throw new IllegalArgumentException("'/' must be followed by an integer in: " + field);
}
} Type guard
boolean hasValidStep(String field) {
int i = field.indexOf('/');
return i == -1 || (i + 1 < field.length() && Character.isDigit(field.charAt(i + 1))); Try / catch
try {
new CronExpression(cron);
} catch (ParseException e) {
if (e.getMessage().contains("'/' must be followed by an integer")) {
// prompt user for a valid step value
}
} Prevention
- Never end a cron field with '/'; always append a step integer.
- When building cron strings programmatically, guard against empty increment segments.
- Use a cron validator utility before persisting user-supplied expressions.
When it happens
Trigger: A cron field ending with '/' such as '*/' (string ends immediately after '/'), or '*/ ' where '/' is followed by whitespace. The parser checks (i+1) >= s.length() or s.charAt(i+1) is space/tab right after the '/' in the '*' or '/' handling branch.
Common situations: Truncated cron string from user input or a template that was incompletely filled, or a copy-paste that dropped the trailing increment digit.
Related errors
- Unexpected end of string.
- Unexpected character: {}
- 'L' option is not valid here. (pos={})
- Unexpected character '{}' after '/'
- '?' can only be specified for Day-of-Month -OR- Day-of-Week.
AI-assisted analysis of xuxueli/xxl-job@e74c784f68 (2026-08-14).
Data as JSON: /api/errors/4b6365d84d268e13.
Report an issue: GitHub.