ClassNotFoundException for transient classes during Vaadin UI restoration
0 reputation · 26 Mar 2024, 21:59 UTC
0 reputation · 26 Mar 2024, 21:59 UTC
The goal is to define a reliable verification approach for recovered UI state after backup restoration in a Vaadin Flow application that uses custom components and Spring-managed entities.
UI serialization persists the component tree as JSON. Custom components must handle transient fields to avoid data loss during restoration. Backend data restoration depends on matching entity schemas, and version mismatches in the serialization format can cause verification failures. Verification of recovered data assumes the underlying database remains intact and does not cover external migrations.
An unresolved design decision concerns client-side SessionStorage persistence of UI state across server restarts and its interaction with session expiry policies.
Should client-side SessionStorage be considered a valid persistence mechanism for UI state across server restarts? What criteria determine component identifier equivalence between a saved snapshot and a restored UI session? How should restoration be defined when the Vaadin minor version has changed the JSON serialization format?
35275 reputation · 26 Mar 2024, 22:46 UTC
Client-side SessionStorage is not a valid persistence mechanism for server-side UI state across server restarts. SessionStorage is browser-tab scoped, cleared on tab close and by browser expiry/privacy policies, and Vaadin Flow does not reconstruct server component instances from it. It is used for client-side navigation hints only.
Restoration after a server restart requires server-side session and state restoration, not client SessionStorage. UI JSON serialization is for client-server sync within a live session, not durable backup.
Likely explanation, not confirmed: a custom component serializes a reference to a non-serializable, Spring proxy, or application-specific class via a field that is not properly marked transient, or the class is absent after classpath change during restore. Deserialization after backup restore then fails because the class cannot be found or is incompatible.
Transient fields that hold required state cause silent data loss on restore if they are not reconstructed. Marking a field transient removes it from serialization.
Equivalence is determined by Vaadin internal state node identity and stable element identifiers, not by user data.
Without all four, the snapshot cannot be safely mapped to a live component.
Treat the snapshot as incompatible. Do not attempt automatic deserialization.
Define restoration as best-effort rebuild of UI from application state with an explicit version gate that rejects incompatible snapshots, or require version pinning for restores. Discard old UI state and recreate the view from backend data.
Which Vaadin minor versions are present in the backup snapshot versus the restore environment, and which class name appears in the ClassNotFoundException. This changes the recommendation on whether to rebuild UI from application state or attempt a version-aligned restore.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.