Solved

rmiregistry on Windows NT

Posted on 1998-02-23
8
427 Views
Last Modified: 2012-05-04
Hi everyone,

I have a demo sample of the RMI code from Java Network Programming from O'Reilly.
A sample of the code follows.
Basically when I start the rmiregistry on my HP-UX box and then I start the
"java HelloImpl", it gives the message Server Ready and I'm able to run my
HelloClient in my client machine.

My problem is that when I start the rmiregistry and the HelloImpl on my NT
box, I don't get any message "Server ready" and my HelloClient fails with the
following message: "java.rmi.NotBoundException: hello"

How can I make it work with Windows NT?

Thanks

Jonny

/* Hello.java */
import java.rmi.*;
public interface Hello extends Remote
{
   public String sayHello() throws java.rmi.RemoteException;
}

/* HelloImpl.java */
import java.rmi.*;
import java.rmi.server.*;
import java.net.*;

public class HelloImpl extends UnicastRemoteObject implements Hello
{
    public HelloImpl() throws RemoteException
    {
       super();
    }
    public String sayHello() throws RemoteException
    {
       return "Truncated";
    }
    public static void main (String args[])
    {
       try
       {
          HelloImpl h = new HelloImpl();
          Naming.rebind("hello",h);
          System.out.println("Server ready");
       }
       catch (RemoteException re)
       {
          System.out.println("Exception: " + re);
       }
       catch (Exception e)
       {
          System.out.println("Malformed: " + e);
       }
    }
}

/* HelloClient.java */
import java.rmi.*;

public class HelloClient
{
   public static void main(String args[])
   {
      System.setSecurityManager( new RMISecurityManager());
      try {
         Hello h = (Hello) Naming.lookup("hello");
         String message = h.sayHello();
         System.out.println("Client: " + message);
      }
      catch (Exception e) {
         System.out.println("Exception: " + e);
      }
   }
}
0
Comment
Question by:Jonny071797
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:ashishagarwal
ID: 1233213
Jonny,

make sure of teh following :

1. You have TCPIP set up and have a hostname/ipaddress for your NT m/c.
2. you have an entry for your hostname in the hosts file:
on NT its in c:\winnt\system32\drivers\etc\hosts

once its up!! then your application shoudl run!!

best of luck!!



0
 

Author Comment

by:Jonny071797
ID: 1233214
Thanks for your help ashishagarwal, but is doesn't help. I have TCP/IP installed and running on my NT workstation.

When I run the HelloClient, it gives me the exception: java.rmi.NotBoundException: Hello

I also tried to move put "rmi://localhost/hello" on the HelloClient but same thing happens.

I believe the problem is on the HelloImpl not finding the rmiregistry.


0
 
LVL 1

Expert Comment

by:alvinwang
ID: 1233215
how about using 127.0.0.1:1099 which is the default port for rmi?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:Jonny071797
ID: 1233216
The same thing happens using localhost, 127.0.0.1:1099, or leaving it "hello" only.

I believe the problem is related to the server (HelloImpl.java).
It should detect that rmiregistry ir running and give me the "Server Ready" message.

0
 
LVL 1

Expert Comment

by:ashishagarwal
ID: 1233217
jonny,

did you check your hosts file ????

do you have a name for your m/c and have an entry for i in your hosts file ???

it is ESSENTIAL to have an hosts entry in the hosts file.. Look at my earlier answer for location for the hostsfile...
0
 

Author Comment

by:Jonny071797
ID: 1233218
my first entry in the hosts file is
127.0.0.1       localhost

I can also ping localhost and it returns 127.0.0.1.
0
 
LVL 1

Accepted Solution

by:
ashishagarwal earned 100 total points
ID: 1233219
Jonny,

We keep working on RMI almost everyday.. and we use the following and it seems to work :

1. We have a hostname for our host say MyHost ( Contol Panel-->network setting->Tcp-ip-> dns --> hostname = myhost

2. have an entry in your hostfile for myhost

myhost xxx.xxx.xxx.xxx

3. use fully qualified url for naming.rebind() in Rmi server
  "//myhost/hello"

4. try out the examples which come with JDK1.1.x.. the tutorial will of of great help !!


0
 

Author Comment

by:Jonny071797
ID: 1233220
Hi Ashishagarwal,

Thanks for your help. It still doesn't seem to work, but I'll have a look at the samples from JDK.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Where to store the queries for modification of table 4 62
Java SE 8u111  Lot of stuff broke 11 69
ForLoop Example 3 48
eclipse console opening separately 2 18
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question