Corda WebService启动异常:节点启动时RPC分页报错
Let me walk you through resolving this issue—it’s a common gotcha with Corda’s RPC vault queries.
What’s causing this error?
The problem is that your node’s Vault contains 201 states, but the vaultTrack RPC call uses a default page size of 200. When you try to track the vault without specifying a custom page size, Corda throws this exception because the result set exceeds the default limit.
How to fix it
You need to explicitly pass a PageSpecification to the vaultTrack method to accommodate the number of states in your Vault. Here’s how to do it in both Kotlin and Java:
Kotlin Example
import net.corda.core.node.services.vault.PageSpecification // Create a PageSpecification with a page size larger than your total state count val pageSpec = PageSpecification(pageNumber = 1, pageSize = 1000) // Adjust pageSize as needed // Pass the pageSpec to vaultTrack val vaultUpdate = proxy.vaultTrack(YourStateType::class.java, pageSpec = pageSpec)
Java Example
import net.corda.core.node.services.vault.PageSpecification; // Define your page specification PageSpecification pageSpec = new PageSpecification(1, 1000); // Set pageSize to a value larger than your state count // Update the vaultTrack call with the page spec Vault.Update vaultUpdate = proxy.vaultTrack(YourStateType.class, pageSpec);
Pro Tip
If you’re dealing with a large number of states long-term, avoid setting an extremely large pageSize (like Integer.MAX_VALUE)—this can lead to memory issues. Instead, implement pagination logic to fetch states in smaller batches. But for startup scenarios where you need to load all states at once, just make sure the pageSize is greater than the total number of states in your Vault.
内容的提问来源于stack exchange,提问作者Javier Garcia Lozano

