RMI uses incorrect InetAddress on machine with two nics

Hello All,
RMI registry and server run on the same host. Host has two nics, one assigned for private network (192.168.x.x) and another for global.
For the sake of creating RMI registry I use the global one and specify it as four dot-delimited numbers instead of machine name:
Registry registry = LocateRegistry.getRegistry("xxx.xxx.xxx.xxx", rmiPort); // "xxx.xxx.xxx.xxx" is global IP addressInvoking a method with just a port as a single parameter causes RMI to bind to the private address, so I avoided that trouble by using numeric IP.
Remote client is able to locate the registry and extract the stub from it now, but ironically retrieved stub contains private address inside.
Debugger shows that the proxy stub contains TCPEndpoint which resolves to 192.168.xxx.xxx:yyyy
I am exporting the object on the server side by using UnicastRemoteObject.exportObject(myObj, 0) method.
Unfortunately, there is no method which would allow to specify the InetAddress to bind the object on.
I've seen the battle on page [Remote Method Invocation (RMI) - Why does RMI server sets its connection address?|http://forums.sun.com/thread.jspa?threadID=5366985].
Close questions are discussed, but I haven't found answer on my question.
Is there an ability to specify the address when exporting the object?
Or any workaround to let the client retrieve the proper stub which can be used to send requests to the server?
Thank,
Alex.

For the sake of creating RMI registry I use the global one and specify it as four dot-delimited numbers instead of machine name:
Registry registry = LocateRegistry.getRegistry("xxx.xxx.xxx.xxx", rmiPort); // "xxx.xxx.xxx.xxx" is global IP address
That doesn't create a registry. It just returns a stub to an existing registry.
Invoking a method with just a port as a single parameter causes RMI to bind to the private address.No it doesn't. It causes RMI to construct a stub using "localhost" as the hostname. If this maps to the private address via your /etc/hosts file or DNS, so be it.
Remote client is able to locate the registry and extract the stub from it now, but ironically retrieved stub contains private address inside.Nothing ironic about it. The stub doesn't know where you got it from. The address inside the stub is controlled by what "localhost" resolves to in the server JVM. If it resolves to something inconvenient, either change that or set the system property java.rmi.server.hostname to the desired IP address or hostname in the server JVM.
Unfortunately, there is no method which would allow to specify the InetAddress to bind the object on.You don't normally need one, see above, although in pathological cases you could use an RMIServerSocketFactory, which does give you that ability.
I haven't found answer on my question.See also the RMI FAQ, item A.1.
Is there an ability to specify the address when exporting the object? See above.

Similar Messages

  • Problem in Rmi in machine with two IP local & internet

    I am having problem in Rmi in machine with two interfaces local & internet
    i.e..
    if I set property java.rmi.server.hostname+ to the one with internet ip address using System.setProperty()
    I can not access Rmi through local LAN
    if I do not set the property Everything works fine in LAN but I can not access the RMI from Internet
    Pls tell me the solution

    Consider the code Here and if you can suggest in this code what changes I have to make ,I will be thankful to you
    // Class MyHelloServer
    package rmi.server;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.Inet4Address;
    import java.net.InetAddress;
    import java.net.MalformedURLException;
    import java.net.NetworkInterface;
    import java.net.SocketException;
    import java.rmi.*;
    import java.rmi.server.ServerNotActiveException;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import javax.swing.JOptionPane;
    import rmi.bl.HelloImpl;
         public class MyHelloServer
              static public ArrayList hostList = new ArrayList();
              static String hostname=null;
              static String SERVER_PORT="9999";
              static String MULTIPLE_BIND="true";
              static{
                   startTest();
              public static void startTest(){
                   try {
                        Enumeration enum1= NetworkInterface.getNetworkInterfaces();
                        while(enum1.hasMoreElements()){
                             NetworkInterface networkInterface = (NetworkInterface)enum1.nextElement();
                             Enumeration enum2 = networkInterface.getInetAddresses();
                             while(enum2.hasMoreElements()){
                                  Object obj = enum2.nextElement();
                                  if(obj instanceof Inet4Address){
                                       if(!hostList.contains(((Inet4Address)obj).getHostAddress())){
                                       hostList.add(((Inet4Address)obj).getHostAddress());
                                            if(networkInterface.isPointToPoint()){
                                                      hostname=((Inet4Address)obj).getHostAddress();
                   }catch (SocketException e) {
                        e.printStackTrace();
                   if(hostname!=null){
                        System.setProperty("java.rmi.server.hostname", hostname);
                   System.out.println(System.getProperty("java.rmi.server.hostname")+"<<<<<< New");
              public static void main(String args[])
               try
                HelloImpl storeServer = new HelloImpl();
                int port=Integer.parseInt(SERVER_PORT);
                String host=InetAddress.getLocalHost().getHostAddress();
                 java.rmi.registry.LocateRegistry.createRegistry(port);
                if(MULTIPLE_BIND.equals("true")){ 
                    for (int i = 0; i < hostList.size(); i++) {
                         System.out.println(hostList.get(i).toString() + " <<<<IP" + i);
                         Naming.rebind("//"+hostList.get(i).toString()+":"+port+"/STORESERVER", storeServer);
                  }else{
                       Naming.rebind("//"+host+":"+port+"/"+"STORESERVER", storeServer);
                MyHelloServer.MyThread thread= new MyThread(":"+port+"/"+"STORESERVER", storeServer);
                System.out.println("Remote Server started.....");
            catch (java.net.MalformedURLException me)
                 System.out.println("Malformed URL: " + me.toString());
                 System.exit(0);
            catch (RemoteException re)
                 System.out.println("Remote exception: " + re.toString());
                 System.exit(0);
            catch (Exception e)
                 System.out.println("Error: " + e.toString());
                 System.exit(0);
         static class MyThread extends javax.swing.JPanel implements ActionListener{
                   String str="";
                   HelloImpl impl;
                   public MyThread(String text,HelloImpl storeServer){
                        this.impl=storeServer;
                        str=text;
                        int timetoWaitForCheck=15000;
                        javax.swing.Timer timer = new javax.swing.Timer(timetoWaitForCheck, this);
                        timer.start();
                          public void actionPerformed(ActionEvent ae)
                             startTest();
                             // Rebind
                                   for (int i = 0; i < hostList.size(); i++) {
                                        try {
                                            Naming.rebind("//"+hostList.get(i).toString()+str, impl);
                                       } catch (RemoteException e) {
                                            e.printStackTrace();
                                       } catch (MalformedURLException e) {
                                            e.printStackTrace();
    }

  • Currently i am using a windows7 installed machine with following configurations intel core i5 2.60Ghz with Ram 8gb.(64 byte).I would like to install Mountain lion osx in my windows machine.Pls tell how to  install  mountain lion osx in my windows machine?

    Currently i am using a windows7 installed machine with following configurations intel core i5 2.60Ghz with Ram 8gb.(64 byte).I would like to install Mountain lion osx in my windows machine.Pls tell how to  install  mountain lion osx in my windows machine?

    Please stop asking about that on this forum.
    There are plenty of informations on the Internet if you want to do it but nobody here will help, because is against the forum's rules.
    And, you can't buy Mountain Lion if you do not have a Macintosh with at least Snow Leopard installed.
    There is no physical media. Mountain Lion is provided by Apple through the Mac App Store.

  • Can i use my ipod 4th generation with two computers?

    can i use my ipod 4th generation with two computers?

    iTunes- How to move the library to an EHD
    Recovering your iTunes library from your iPod or iOS device
    iTunes- Back up your iTunes library by copying to an external hard drive

  • Operating system not found when deploying to machines with two hard drives using MDT 2013.

    Computers with two hard drives will not boot after the install OS step in the task sequence.  I get the "An operating system wasn't found.  Try removing drives that don't contain an operating system" error.  I am able to get the
    machine to boot by swapping the hard drives' boot order, but the  task sequence won't complete after this.  The deployment works fine on machines with one hard drive, and I'm not getting any errors from the task sequence.  I'm deploying windows7
    enterprise x64 using MDT2013.  This is a new custom image and task sequence generated using MDT2013.  I can't remove the second hard drive because there are scripts that run on the second hard drive during deployment and also because I don't desire
    to remove and re-install 250 hard drives.  I've not experienced this problem with earlier versions of MDT.

    The bdd.log file you sent does not show two internal drives, it shows only one.
    Console > Please wait while DiskPart scans your configuration... ZTIDiskpart 12/16/2013 9:57:04 AM 0 (0x0000)
    Console > DiskPart has finished scanning your configuration. ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > DISKPART> ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > Disk ### Status Size Free Dyn Gpt ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > -------- ------------- ------- ------- --- --- ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > Disk 0 Online 60 GB 60 GB ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > DISKPART> ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > Volume ### Ltr Label Fs Type Size Status Info ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > ---------- --- ----------- ----- ---------- ------- --------- -------- ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Console > Volume 0 D DVD-ROM 0 B No Media ZTIDiskpart 12/16/2013 9:57:05 AM 0 (0x0000)
    Is this the problem?
    Keith Garner - keithga.wordpress.com

  • Using Time Machine with two external hard drives

    Hi. I use Time Machine to back up the hard disk on my MacBook Pro onto a Western Digital external drive. For secure storage of family photos and things we don't want to lose, I would like to do the following:
    For a week or two, back up my MacBook Pro onto a Western Digital drive. Let's call this WD Drive 1. Then walk downstairs and put WD Drive 1 in a fireproof safe. For the next week or two, back up my MacBook Pro onto a different Western Digital drive. Let's call this WD Drive 2. Then put WD Drive 2 in the safe, take out WD Drive 1, and use WD Drive 1 as the back-up medium for the next week or two. Then keep alternating between WD Drive 1 and WD Drive 2 every couple weeks. This way, I will always have up an to date back-up on the WD drive that is connected to the MacBook Pro, and I also will have a two-week old back-up on the WD drive in the safe in case of a fire or something.
    Can Time Machine be used in this manner, alternating between two different external back-up disks? Will Time Machine "know" when I change external drives and manage all back-up files appropriately?
    Thank you!

    pomme4moi wrote:
    Can Time Machine be used in this manner, alternating between two different external back-up disks? Will Time Machine "know" when I change external drives and manage all back-up files appropriately?
    Yes. Each drive will have an independent set of backups; and each will be a complete "snapshot" of the way your system looked at the time of the backup.
    When you swap drives, the first backup will be somewhat longer, and may involve a "deep traversal," while Time Machine "catches up" with all the changes since the last backup to that drive.
    And try not to go too long between swaps; it's undocumented, so we don't know the exact parameters, but after at least 10 days (apparently), Time Machine may do a new, full backup instead of an incremental one of changes only.
    And you only need to worry about Time Machine deleting old backups if you've deleted the originals from your system; TM will never delete the backups of anything that's still there.
    But . . .
    As MusicWind says, thats' probably not the best strategy. One of the reasons you want dual backups is because no hardware is perfect -- it all fails, sooner or later, right? Similarly, no app is perfect, either. The "works" of Time Machine are more complex than most backup apps; it's pretty reliable, but if you're going to have dual backups, you're probably a bit safer with a different app for your secondary backups.
    I don't know about SuperDuper, but CarbonCopyCloner does have an "archive" feature, where it will keep copies of things you've deleted. I've never used it, so don't know just how it works.
    Also see Kappy's post on Basic Backup, complete with links to the web sites of each product.
    p.s.: Don't try copying Time Machine's dated folders; you'll get a complete copy of your entire system.

  • Time Machine with two computers - "You do not have sufficient access privileges"

    I am currently running an Intel-based iMac at home and was recently given a new Intel-based MacBook Pro to use for work.  The iMac at home is running Leopard and the MacBook is running Snow Leopard.  After I loaded all of the necessary files from the home computer to the work computer (using the files on my external that I use for time machine backups), I decided to use the same external hard drive to use as the Time Machine for both computers.  However, now whenever I try to access the Time Machine Backups from the opposite computer, I am told that I "do not have sufficient access privleges."  E.g., when I try to open the TM MacBook files on the iMac or vice versa, I recieve this message.  Opening the files that were backed up on the same computer is no problem.
    Any thoughts? Thanks!

    kabbydriver- No, no, no, no no! Do not screw around with permissions on the sparse bundle or the mounted disk image. Dude, this is the third bad advice from you I've read in the last hour. Isn't it enough that one of your responses violated the forum terms of use and had to be deleted? It's time to give it a rest; come back another day.
    UCOdoublebass- You need to create a different Time Machine backup for each Mac. Two Macs cannot backup to the same Time Machine backup image. Read this to get started learning about your options:
    http://www.macworld.com/article/131841/2008/01/multiplebackup.html

  • Can I use the same nike+ sensor with two differet Ipods and register the trainings in onmly one account?

    Hello, I would like to know if I can use the same nike  Ipod sensor with two different ipods. I want to use the same sensor sometims with an Ipod touch and sometimes with an Ipod Nano, I want my trainings with both Ipods to be registered to the same account. I want them to be registered to only one account, not as it had been used by two different people.

    Of course. You should use the same AppleID on all your devices. Why would you create a new one?
    Matt

  • SCCM central site and primary site use the same SQL SERVER with two Instance.

    Hi  Guys,
    I want deploy SCCM 2012 central site and primary site in my domain. But Only one Sql server for me. Any one can tell me how to install the central site server and primary site server with the same SQL SERVER with two instance.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Sean Xiao
    TechNet Community Support

    Although you can install like the configuration you said above, we do not recommend you do it this way. If your SQL box has  problems, all the data will go away and you will not have data redundancy.
    You need to configure the different SQL Port and SQL Broke service port e.g.
    SQL port 4023  SQL Broke Service port 4022 for CAS instance
    SQL port 4024  SQL Broke Service port 4021 for PRI instance
    Juke Chou
    TechNet Community Support
    I agree with Johan and this configuration should not be used. But I want to clarify that the default ports for "SQL port" (actually, SQL over TCP) is 1433 and the SQL Broker Service uses 4022. The configuration above should work but the "correct" would be
    to use 1433 and 4022 for the CAS and 10434 and 4023 for the Primary :)
    You can read more about Network Ports used by Configuration Manager here
    http://technet.microsoft.com/en-us/library/hh427328.aspx#BKMK_CommunicationPorts
    /Tim
    Tim Nilimaa | Blog: http://infoworks.tv | Twitter: @timnilimaa

  • Have been told if you use the same itunes account with two iphone you will receive each others text messages, is this true

    Have been told if you use the same itunes account on two iphones, you will receive each others text messages, is this true?

    you can use the same itunes id for purchases and so on, but have separate icloud id's for imessaging and all the icloud stuff. it's not preferable, but it isn't a problem either.
    http://support.apple.com/kb/HT4895?viewlocale=en_US&locale=en_US

  • Can I use an external Drum Machine with the drum sounds in Express?

    New to Logic Express and Midi. Can I create drum track patterns and whole songs using an external drum machine and the drum sounds in Logic Express? I'm sure I can, but I have no clue as to how. Can anyone point me in the right direction?

    shanec805, wttdaWelcome to the discussion area!
    Remember that Time Capsule is a hardware device.
    Time Machine is a software feature of OS X 10.5.5.

  • IP Address with two NICs

    LabVIEW 7.0
      I have Win2000, my client has XP Pro.
      My program, as a convenience, displays on the front panel the IP address of the machine it's running on. This is so he can enter this address in another machine and communicate with it.
      I'm using the STRING to IP function (input unwired), and the IP to STRING function to display the number.
      My client has TWO NICs installed - one for data acquisition (we are collecting data from Ethernet machines in a test cell), and another for general traffic (printing, inter-cell transfer, etc).
      We discovered recently that the program was displaying the local IP number (192.168.x.x), which is the DAQ net. This is not the one we want.
      So I found the MULTIPLE OUTPUT option on the STRING to IP function and turned it on. I used an INDEX ARRAY function to pick out address #1 (not #0) and display that. That works fine.
      My question is: how do I know that #1 is the right number to use? This app will be deployed on a bunch of machines, will the local be Net #0 on all machines? Is that a system config issue? Do I need to tell him to configure a control panel somewhere a certain way? Do I need to read both addresses and display the one that does NOT start with "192."? How do I make this bulletproof?
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    Hi CMB,
    There are several approaches to this.  Some less favorable to others... such as at one extreme:  to identify with a label which NIC goes to what network....
    However,  to keep automation... "automated", how about the following: 
    Since you can automatically detect each IP address, you can then implement a small test to "self-discover" which IP (NIC) talks tho which network.  For instance, you may want to ping a known static address, such as a mail-server to discover that it is part of the WAN and not the test network.  You may also prefer to ping by host name just in case the IP address of that machine changes.   In the event that you do not know any IP address or host names, you may try to ping something outside the LAN (over internet for instance), something that the test network could not reach (your own website for instance??).
    Would you be autodetecting on an ongoing basis (ie. every day) or only during equipment setup and configuration?
    Ray

  • How do you use time machine with two macs?

    I have an external hard drive hooked up to one of my macs. How do I get it to back up both macs?

    You create the password for someone when you add them as a user under Users box in the Sharing Preferences > File Sharing. you have to click the plus sign under the users box to see this come up. you will get a mini address book looking thing, but I suggest just hitting the New Person button. you will see a dialog that asks for this new persons name AND password.
    So lets say you want to share HardDisk123.
    1) First you add HardDisk123 to the Shared Folders list on the left.
    2) Then, making sure HardDisk123 is selected, you click the plus + under users on the right.
    3) In the window that opens, you click "New Person" and create a username and password.
    4) Once you OK out of that window, set that new persons permissions (Read & Write, Read only, etc), using the little up and down arrows next to their name.
    Now you have shared HardDisk123, and created a new account that can access HardDisk123. That new account doesn't have access to anything else on your computer.
    Enabling SMB sharing (in Options) is a global setting. Its confusing because you may see 1 or more users in the list there. But those are not really the same users we were just dealing with (although there could be overlap). The list of users that appear under SMB sharing in that options page is users that have an account on your computer. When you start up your computer, if you don't have automatic login set up, you are prompted to , well LOG IN. Thats how you can have a whole family of different users on one computer. They each log in separately and all have different desktop backgrounds, screen saver settings, etc etc. It how you keep your kids from deleting all your files. Well, if you have multiple user accounts setup (in the Accounts preference pane) then they will show up here under SMB and you can individually enable SMB sharing for all or just a few of those users. When you try to do that, it asks for a password.
    So don't confuse those users, with accounts you create to give people on your network access to your folders on your computer.

  • Using same external hard drive with two Macs

    I use two Lacie external hard drives and Time Machine to back-up my iMac, swapping over the drives each week to have one off-site.
    I am soon to buy a MacBook. Can I use the same external hard drives for the MacBook's Time Machine back-ups, whilst continuing to use them with the iMac, or will that cause problems?
    Thank you.

    As Kappy says, Time Machine will put both sets of backups in the same Backups.backupdb folder. That may not be a good idea for the future; your best bet may be to partition the drive.
    See #4 in the Frequently Asked Questions *User Tip,* also at the top of this forum.

  • Using Lightroom on a Cloud with Two Computers / Different Cities

    I would like to use Lightroom on two Macs in two different cities.  What I would like to do is move photo files to a Cloud system such as Dropbox work with them on a computer in city A then travel to city B and work on them with a different computer.  I think this is possible if I also place the .ircat file for the pictures I'm working with in the same folder / Cloud system.  Will this work?  Thanks

    They've always been separate and I agree he doesn't have to sync them
    Yes, the previews themselves have always been separate from the catalog. But the "preview directory", i.e. the database tables that linked the images with their preview files, has been inside the catalog until LR3.
    That created a bit of a trouble for those that had a "copy entire catalog" workflow, the OP was talking about. Namely, even if you had all previews built on both machines, copying a catalog from machine A, invalidated the preview cache on machine B, since the "preview tables" were now pointing to different preview files. And we now that building a new cache takes many hours.
    Thankfully, in LR3 those tables had been moved to a separate SQLite database (previews.db file in the root of the preview cache).

Maybe you are looking for