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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:50:56+00:00 2026-06-05T08:50:56+00:00

I have a RMI server running on the localhost, exporting an object of type

  • 0

I have a RMI server running on the localhost, exporting an object of type Message:

try {
    MessageServer obj = new MessageServer();
    Message stub = (Message) UnicastRemoteObject.exportObject(obj, 0);
    Registry registry = LocateRegistry.getRegistry();
    registry.bind("M", stub);
} catch (RemoteException e) {
} catch (AlreadyBoundException e) {
}

Then I want to start a client and get the stub for this object. It seems that the registry is found but then in the try block a NotBoundException is thrown:

java.rmi.NotBoundException: M
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:136)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at rmitest.MessageClient.main(MessageClient.java:23)

public static void main(String args[]) {
        //String host = "localhost";
        Registry registry;
        Message stub = null;
        try {
            registry = LocateRegistry.getRegistry();
            stub = (Message) registry.lookup("M"); //NotBoundException thrown here
        } catch (NotBoundException ex) {
        } catch (AccessException ex) {
        } catch (RemoteException ex) {
        }
        try {
            stub.insert("TestString"); //NullPointerException here
        } catch (RemoteException ex) {
        }

}

Why is "M" not found? Both server and client are started inside Netbeans, the registry is started via terminal beforehand.

  • 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-05T08:50:57+00:00Added an answer on June 5, 2026 at 8:50 am

    RMI is sort of a beast, it’s always an issue how to run it.

    First of all, do proper exception handling as @EJP suggested: a reason might be you get a connection timeout or something similar – so put an e.printStackTrace() into the catch blocks and let’s see if we get sort of an error message (btw you gonna stop creating empty catch blocks really quickly when you debug a suppressed exception for 2 days). Can’t it be your firewall that catches the connection?

    I would also change getRegistry() to createRegistry(), and bind() to rebind() (it can save you a bit of time).

    The exception you’re getting is because your main application wasn’t able to bind (register) the service you wanted, and it is missing (unavailable) from the default registry.

    RMI can be done several ways. The approach you chose is absolutely cool for development and in testing, but you’ll need to do some changes if you want to put it under production (e.g., probably there will be a common rmiregistry running somewhere, you’ll have to use a policy file and some properties like java.rmi.codebase=..., you’ll need a proper security manager installed, etc.)

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

Sidebar

Related Questions

I have used Naming.rebind(rmi://localhost:1099/RmiServer, c); where c is a remote object. And XYZ robj=new
I'm using RMI and I have a server object and many clients that connected
I have an RMI Server which correctly binds to an RMI Registry when running
I have an RMI server that is using a class from another project. I
I have several clients all referencing the same remote object through RMI, and I
I have functioning RMI client-server system. The server's host information is known to the
I have written a Server that receives RMI requests and performs some operations. For
Hi I have RMI application and now I try to invoke some methods at
I have a client that starts a long running process on the server. At
I am adapting a little rmi client-server application. I have written several things :

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.