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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:41:08+00:00 2026-05-26T04:41:08+00:00

Scenario: I’m implementing an RMI example between 2 PCs where the Controller PC queries

  • 0

Scenario:
I’m implementing an RMI example between 2 PCs where the Controller PC queries the Agent PC for information. The agent PC may run Xen or KVM , hence the implementations of the queries differ(Reason for using RMI).
On the Agent’s side I’m running 2 RMI registries bound to two different ports. When the same example is carried out with just 1 Registry on the agent’s side, everything works fine.

Here is my code:
Controller. java(contains main() on controller’s side):

public class Controller {

NetworkDiscovery n;
public static int discoveryInterval=2000;
static public PM pmlist;

public static void main(String[] args) throws UnknownHostException,NotBoundException, `   MalformedURLException, RemoteException {

pmOperations pm=(pmOperations)Naming.lookup("rmi://Agent_IP/RMIService1");
boolean l= pm.CreateVM("apple3","/var/lib/libvirt/images",1,200);
System.out.println(l);

vmOperations vm=(vmOperations)Naming.lookup("rmi://Agent_IP/RMIService2");
boolean ShutdownVM = vm.ShutdownVM("apple1");
System.out.println(ShutdownVM);
//other code
}

pmOperations.java(on controller’s side)(on the agent’s side, it has the same defn with implementation code inside function)

public interface pmOperations extends java.rmi.Remote{
    public boolean CreateVM(String vmName,String imgSrc, int allotCPU, int allotMem )
    throws java.rmi.RemoteException;
}

vmOperations.java(on controller’s side)(on the agent’s side, it has the same defn with implementation code inside function)

public interface vmOperations extends java.rmi.Remote{
    boolean ChangeVMParam(String vmName,String paramName,String paramValue)
    throws java.rmi.RemoteException;
}

Agent.java

public class Agent {

Agent() throws RemoteException, MalformedURLException{
    Registry RMIService1 = LocateRegistry.createRegistry(1099);

    Registry RMIService2 = LocateRegistry.createRegistry(4478);

        vmOperations vmOp = new kvmVM();
        pmOperations pmOp = new kvmPM();

      Naming.rebind("rmi://localhost:1099/RMIService1", pmOp);
      Naming.rebind("rmi://localhost:4478/RMIService2", vmOp);
}

public static void main(String[] args) throws SocketException, UnknownHostException, IOException, LibvirtException {

        System.out.println("Inside main ");
        new Agent();
        //other code
}
}

Error I get while running above code on controller’s side-no error on agent side:

Exception in thread “main” java.rmi.NotBoundException: RMIService2
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:106)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at package1.Controller.main(Controller.java:43)

Thanks!

  • 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-26T04:41:09+00:00Added an answer on May 26, 2026 at 4:41 am

    You can’t create two Registries in the same JVM.
    You don’t need two Registries in the same host.
    You don’t need to create two instances of the remote object.

    Just create one Registry, one remote object, and bind it to the Registry twice, once with each name. You don’t really need to bind it twice either really either. There’s a lot of pointless duplication in this design.

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

Sidebar

Related Questions

Scenario: I have a UITabBar on the top of my view controller. There are
Scenario: I run the find code issues function in resharper. I go one by
Scenario Route: /template/customize/10 Where: 10 = ID of Template() In the controller the model
Scenario: A stored procedure receives from code a DateTime with, let's say DateTime.Now value,
Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario: Attempting to import many (>100), large(>1M recs) flat-files (csv). Problem: Many records are
Scenario: I'm currently writing a layer to abstract 3 similar webservices into one useable
Scenario is that we send out thousands of emails through SMTP server. Content is
Scenario: An event is raised in class A that needs to be handled by
Scenario I have two wrappers around Microsoft Office, one for 2003 and one for

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.