quarkusio/quarkus · error · UnsupportedOperationException
Cannot call a page related method, call page(Page) or page(i
Error message
Cannot call a page related method, call page(Page) or page(int, int) to initiate pagination first
What it means
CommonReactivePanacheQueryImpl supports page-based navigation only after pagination has been initialized. Page navigation methods (nextPage, previousPage, firstPage, lastPage, hasNextPage, hasPreviousPage) call checkPagination() which throws UnsupportedOperationException when page is null.
Source
Thrown at extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/CommonReactivePanacheQueryImpl.java:131
}
public Uni<Integer> pageCount() {
checkPagination();
return count().map(count -> {
if (count == 0)
return 1; // a single page of zero results
return (int) Math.ceil((double) count / (double) page.size);
});
}
public Page page() {
checkPagination();
return page;
}
private void checkPagination() {
if (page == null) {
throw new UnsupportedOperationException(
"Cannot call a page related method, "
+ "call page(Page) or page(int, int) to initiate pagination first");
}
if (range != null) {
throw new UnsupportedOperationException("Cannot call a page related method in a ranged query, " +
"call page(Page) or page(int, int) to initiate pagination first");
}
}
public <T extends Entity> CommonReactivePanacheQueryImpl<T> range(int startIndex, int lastIndex) {
this.range = Range.of(startIndex, lastIndex);
// reset the page to its default to be able to switch from page to range
this.page = null;
return (CommonReactivePanacheQueryImpl<T>) this;
}
public <T extends Entity> CommonReactivePanacheQueryImpl<T> withCollation(Collation collation) {
this.collation = collation;View on GitHub (pinned to e1c734241f)
Solutions
- Call query.page(0, size) (or page(Page.of(...))) before any page navigation method
- If you used range(start, end), do not call page-related methods — iterate results directly
- Check hasNextPage only after initializing pagination
Example fix
// before
var query = Customer.find("active", true).range(0, 10);
query.hasNextPage(); // throws
// after
var query = Customer.find("active", true).page(0, 10);
query.hasNextPage(); Defensive patterns
Strategy: validation
Validate before calling
ReactivePanacheQuery<Customer> q = Customer.find("active", true);
q.page(0, 20); // initialize pagination before any page navigation Try / catch
try {
boolean more = query.hasNextPage();
} catch (UnsupportedOperationException e) {
query.page(0, 20);
boolean more = query.hasNextPage();
} Prevention
- Always call page(Page) or page(int,int) right after creating the query
- Never mix range() with page navigation methods
- Wrap query construction in a helper that guarantees pagination setup
When it happens
Trigger: Calling nextPage()/previousPage()/firstPage()/lastPage()/hasNextPage()/hasPreviousPage() on a ReactivePanacheQuery without first calling page(Page) or page(int, int); also thrown when a range query (range(start,end)) was used instead of paging.
Common situations: Using range(...) then asking about pages; assuming a fresh query() result starts at page 0 automatically; porting blocking Panache code expecting the same defaults.
Related errors
- No current Vertx context found
- Stateless operations not supported
- Blocking gRPC client call made from the event loop. If the c
- Attempting to boot a blocking Hibernate ORM instance on a re
- @Transactional cannot start a JTA transaction within a react
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/dfce700128f18f59.
Report an issue: GitHub.