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 9015779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:50:06+00:00 2026-06-16T03:50:06+00:00

I have an RMI application, with details below. The server knows it is creating

  • 0

I have an RMI application, with details below. The server knows it is creating a DocumentProvider object, and passes a reference to that object to the client using Document interface. When the client passes the Document object to the server, the server can no longer cast this into DocumentProvider, though that’s what the server originally created.

Is there a way to do this kind of cast, i.e. the server knows it’s creating a particular implementation of Document with more internal features (in this case, the InternalClass serverInfo), and wants to access those additional features in its implementation of the Document functions (in this case in the “doCast()” function).

Another way of asking: Once the server creates a DocumentProvider object, is that object sitting on the server? And if so, how can I give the client a reference to it? the InternalClass serverInfo; part is NOT serializable, and cannot be transferred to the client. (Somewhat like a file handle, etc., though I can keep it and manage it within the DocumentProvider class).

//Interface
public interface Document extends extends java.rmi.Remote {
        public String doSomething()  throws java.rmi.RemoteException;
        public String doCast()  throws java.rmi.RemoteException;
}

//The server:
    public class DocumentProvider extends java.rmi.server.UnicastRemoteObject implements java.rmi.Remote, Document {
        InternalClass serverInfo;

        public String doSomething()  throws java.rmi.RemoteException {
            return "DocumentProvider doing something";
        }
        public String doCast(Document d)  throws java.rmi.RemoteException {
            DocumentProvider d2 = (DocumentProvider) d; // this cast fails, even when d was a DocumentProvider class
            // then access d.serverInfo, etc.
        }
    }

public interface DocumentFactory extends extends java.rmi.Remote {
        public Document createDocument() throws java.rmi.RemoteException;
}
public class DocumentProvider extends java.rmi.server.UnicastRemoteObject implements java.rmi.Remote, DocumentFactory {
    public Document createDocument() throws java.rmi.RemoteException {
        return new DocumentProvider();
    }
}

//Client app:
main()... {
    DocumentFactory dFactory = (lookup/resolve this; this works ok);
    Document dMain = dFactory.createDocument();
    dMain.doCast(dMain);  // this fails because
}

To elaborate, “InternalClass serverInfo” is a non-serializable 3rd party “handle”, I must somehow keep its state in the server, so the main question is how to do that, while returning a reference to a remote object, allowing the client to “manipulate” that internal object through remote calls which are defined in the interface. (Another easier example: if serverInfo were a file handle, and I allow the client to do “seek” and “read” functions through the Document interface)

  • 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-16T03:50:08+00:00Added an answer on June 16, 2026 at 3:50 am

    Remote objects are passed and returned as stubs which implement the same remote interface. Casting to the actual remote object class therefore cannot possibly work, and trying to do it remotely makes even less sense. Just use the stub as an instance of the interface. If that isn’t sufficient there is something wrong with your design.

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

Sidebar

Related Questions

I am writing a client-server application using Java-RMI. Some server-side ressources have to be
I have an RMI server that is using a class from another project. I
I am programming a simple client/server application using Java-RMI. I would like to know
I have a simple RMI 'compute' server application (similar to this ) that accepts
I am adapting a little rmi client-server application. I have written several things :
In our application, we are using RMI for client-server communication in very different ways:
I have created below bat file to run my RMI server @echo Off set
I have a Java client - server application. The client is designed to run
I have exposed methods for remote management in my application server using JMX by
We have J2EE application built using Hibernate and struts. We have RMI registry based

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.