Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9222983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:57:53+00:00 2026-06-18T03:57:53+00:00

I am using jsonrpc4j and got stuck. I made a little example to show

  • 0

I am using jsonrpc4j and got stuck. I made a little example to show my problem:

Abstract class:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
@JsonSubTypes(value = { @JsonSubTypes.Type(value = Walnut.class) })
public abstract class Nut {

}

Concrete subclass:

public class Walnut extends Nut {

}

Interface for the service:

public interface ServiceInterface {
    public Nut getNut();
    public void setNut(Nut nut);
}

The service itself:

public class Service implements ServiceInterface {
    public Nut getNut() { return new Walnut(); }
    public void setNut(Nut nut) {}
}

Server:

JsonRpcServer rpcServer = new JsonRpcServer(new ObjectMapper(), new Service());
StreamServer streamServer = new StreamServer(rpcServer, 50, 1420,
        50, InetAddress.getByName("127.0.0.1"));
streamServer.start();

Client:

JsonRpcClient jsonRpcClient = new JsonRpcClient(new ObjectMapper());
ServiceInterface remoteService = ProxyUtil.createClientProxy(
        ServiceInterface.class.getClassLoader(),
        ServiceInterface.class, jsonRpcClient,
        new Socket(InetAddress.getByName("127.0.0.1"), 1420));

If i call remoteService.getNut() everything works as expected, the log prints:

JSON-PRC Request: {"id":"6064348714687420633","jsonrpc":"2.0","method":"getNut"}
JSON-PRC Response: {"jsonrpc":"2.0","id":"6064348714687420633",
        "result":{"@type":"Walnut"}}

If i call remoteService.setNut(new Walnut()) the server throws an exception, the log prints:

JSON-PRC Request {"id":"9194853851254039397","jsonrpc":"2.0",
        "method":"setNut","params":[{}]}
Error in JSON-RPC Service com.fasterxml.jackson.databind.JsonMappingException:
        Unexpected token (END_OBJECT), expected FIELD_NAME:
        missing property '@type' that is to contain type id  (for class Nut)

The type information of the parameter is missing because the proxy wraps all parameters into one object array (see my last question to understand why the info type is missing in this case).

How can i achieve the desired serialization? I tried to enable default typing and to annotate (with @JsonTypeInfo) the Object.class via mix-in, but both failed (exceptions below).

With enabled default typing [remoteService.getNut(), error on server side]:

Exception while handling request
        com.fasterxml.jackson.databind.JsonMappingException:
        Unexpected token (START_OBJECT), expected START_ARRAY:
        need JSON Array to contain As.WRAPPER_ARRAY type information for
        class com.fasterxml.jackson.databind.JsonNode

With enabled default typing [remoteService.setNut(new Walnut()), error on client side]:

Exception in thread "main" java.lang.IllegalArgumentException:
        Unexpected token (START_ARRAY), expected VALUE_STRING:
        need JSON String that contains type id (for subtype of
        com.fasterxml.jackson.databind.JsonNode)

With mix-in [remoteService.getNut(), error on server side]:

Exception while handling request
        java.lang.IllegalArgumentException:
        Could not resolve type id 'DefaultErrorResolver$ErrorData'
        into a subtype of
        [simple type, class com.fasterxml.jackson.databind.JsonNode]

With mix-in [remoteService.setNut(new Walnut()), error on client side]:

Exception in thread "main" java.lang.ClassCastException:
        [Ljava.lang.Object; cannot be cast to
        com.fasterxml.jackson.databind.JsonNode

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:57:54+00:00Added an answer on June 18, 2026 at 3:57 am

    I solved my issue by patching the library. Now it serializes all parameters one by one and concatenate them afterwards. Bug report and patch can be found at http://code.google.com/p/jsonrpc4j/issues/detail?id=49.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the example provided in jQueryUI tutorial: jQuery UI Draggable + Sortable When I
Using 2 dropDownLists in repeater row how does one use the 1st one as
Using the example here as a starting point, I set out to customize my
Using this as an example, how could I scale the graphic such that it's
Using ember 1.0.0-pre3 I have a little app that has this code: window.App =
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
Using C# How can I show a document in richtextbox without scrollbars, But I
I am trying to make a json call using C#. I made a stab
i am using JSON-RPC PHP from http://jsonrpcphp.org/?page=example&lang=en to create php jsonrpc as server and
Using C#, I want to show the image in the Access column but failed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.