Repository navigation
Vaadin 25: JsonArray parameters in @ClientCallable methods fail to deserialize #102
Description
Describe the bug
Adding a child (or sibling) to a node in the Edit Chart demo fails on Vaadin 25 with a server-side deserialization error.
OrgChart declares @ClientCallable methods that take an elemental.json.JsonArray parameter:
OrgChart#onChildrenAdded(String nodeId, JsonArray childIds)OrgChart#onSiblingsAdded(String nodeId, JsonArray siblingIds)
In Vaadin 25, RPC arguments are decoded with JacksonCodec, which cannot instantiate elemental.json.JsonArray (abstract type, no creators), so the invocation fails and the children/siblings are never added on the server side.
[qtp2075982863-59] ERROR com.vaadin.flow.server.DefaultErrorHandler - Unexpected error: Cannot deserialize JSON to type elemental.json.JsonArray: Cannot construct instance of `elemental.json.JsonArray` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [No location information]
java.lang.IllegalArgumentException: Cannot deserialize JSON to type elemental.json.JsonArray: Cannot construct instance of `elemental.json.JsonArray` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [No location information]
at com.vaadin.flow.internal.JacksonCodec.decodeAs(JacksonCodec.java:259)
at com.vaadin.flow.server.communication.rpc.DefaultRpcDecoder.decode(DefaultRpcDecoder.java:49)
at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.decodeArg(PublishedServerEventHandlerRpcHandler.java:332)
at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.decodeArgs(PublishedServerEventHandlerRpcHandler.java:268)
at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:222)
...
Caused by: tools.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `elemental.json.JsonArray` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [No location information]
at tools.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:70)
at tools.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1995)
at tools.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:511)
at tools.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1525)
at tools.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:254)
at tools.jackson.databind.deser.DeserializationContextExt.readRootValue(DeserializationContextExt.java:266)
at tools.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:2610)
at tools.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:978)
at tools.jackson.databind.ObjectMapper.treeToValue(ObjectMapper.java:1291)
at com.vaadin.flow.internal.JacksonCodec.decodeAs(JacksonCodec.java:255)
... 58 more
Expected behavior
Adding a child/sibling to a node works without server-side errors on Vaadin 25.
The @ClientCallable methods should use a parameter type that Vaadin 25 can decode (e.g. com.fasterxml.jackson.databind.node.ArrayNode, or a plain int[]/Integer[]) instead of elemental.json.JsonArray.
Minimal reproducible example
- Run the demo with the
v25profile. - Open the Edit Chart demo.
- Add a child to a node.
- The error above is logged in the server console.
Add-on Version
5.4.0-SNAPSHOT
Vaadin Version
25
Additional information
Reported by @paodb in #101 (review) — unrelated to that PR's changes.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix: decode node IDs as string in ClientCallable methods