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

  • Home
  • SEARCH
  • 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 6540717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:00:48+00:00 2026-05-25T11:00:48+00:00

Hello everyone, I have been banging my head really hard trying to solve this

  • 0

Hello everyone,

I have been banging my head really hard trying to solve this problem. I really appreciate if anyone can please have a look at my problem and help me.

I have multiple clients that uses Java RMI to establish a connection (register()) and receive a list of connects clients from the server (get()). My goal is to get clients to talk to each other using RMI, without having to register themselves, only the server so far is being register.

I am trying to pass a reference of the client object to the server.

I am getting the following error:

java.rmi.MarshalException: error marshalling arguments; nested exception is: 
    java.io.NotSerializableException: Client

I do not want to use Serialization (I believe), as I don’t want to pass the object itself, but a reference. Client1 should be able to send a message to Client2 by calling client2.messsage(String username, String message);

I believe I should just show you at this point how I have implemented my code:

public interface RMIClientIntf extends Remote {
    public void message(String name, String message) throws RemoteException;
    public String getName() throws RemoteException;
}

The previous code is what all clients should implement. If the message() function gets called from another client, that means the other class is sending a message.

My client class itself:

public class Client implements RMIClientIntf {
    public Client() throws RemoteException { super(); }
    public String getName() throws RemoteException { }
}

Now, the Main class that creates an instance of client calls the following, to send the remote object to the server:

final Client client = new Client();
server.register((RMIClientIntf) client, name);

On the server side, the register method is defined as:

public interface RMIServerIntf extends Remote {
    public String register(RMIClientIntf cl, String userName) throws RemoteException;
    public RMIClientIntf[] get() throws RemoteException;
}


public class Server extends UnicastRemoteObject implements RMIServerIntf {
    public String register(RMIClientIntf cl, String userName) throws RemoteException {
        ClientStruct newClient = new ClientStruct(cl, userName);
        /* Store the ClientStruct */
        return new String("SUCCESS");
    }
}

After registering, each client will request the list of connected users. The function in the server is the following:

public RMIClientIntf[] get() throws RemoteException {
    RMIClientIntf[] users = new RMIClientIntf[openConnections.size()];
    /* Fill in users from ClientStruct */
    return users;
}

If Client were to also implement Serializable, then the program runs but when client2 calls client1.message(), the message() method gets called for client2 and throws a NullPointer at this point.

I was looking at this link: http://www.exampledepot.com/egs/java.rmi/args_Args.html, which gave me a hint that it should implement Remote but not Serialization to pass by reference. I am not sure why the program is complaining in my case.

I really appreciate any help I can get. I’ve been trying to fix this problem for a while and I can’t seem to find any solution.

Thank you very much!

  • 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-05-25T11:00:49+00:00Added an answer on May 25, 2026 at 11:00 am

    you need to export Client and send the stub to the server

    edit: this should work, it should the same way you exported the server (but without using the rmiregistry)

    server.register((RMIClientIntf) UnicastRemoteObject.exportObject(client,0), name);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello everyone I have some problem with understanding this piece of the code: import
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello everyone I'm trying to work with jboss messaging, does anyone knows the default
Introduction : Hello Everyone, I have been looking for days for a way to
Hello everyone I been trying get php uploader working but having a lot of
Hello everyone i currently have this: import feedparser d = feedparser.parse('http://store.steampowered.com/feeds/news.xml') for i in
hello everyone I have this snippet of the code: local helper(f, i, j) =
hello everyone I have this snippet of the code: local fun NTimesF(f, n:int) =
hello everyone I have this snippet of the code: void* Init(int N) { Hand
Hello everyone I have a problem I'll try to describe shortly In our application

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.