Jonny071797
asked on
rmiregistry on Windows NT
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.NotBoundExceptio n: 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("Except ion: " + re);
}
catch (Exception e)
{
System.out.println("Malfor med: " + 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("Except ion: " + e);
}
}
}
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.NotBoundExceptio
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
}
catch (RemoteException re)
{
System.out.println("Except
}
catch (Exception e)
{
System.out.println("Malfor
}
}
}
/* HelloClient.java */
import java.rmi.*;
public class HelloClient
{
public static void main(String args[])
{
System.setSecurityManager(
try {
Hello h = (Hello) Naming.lookup("hello");
String message = h.sayHello();
System.out.println("Client
}
catch (Exception e) {
System.out.println("Except
}
}
}
ASKER
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.
When I run the HelloClient, it gives me the exception: java.rmi.NotBoundException
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.
how about using 127.0.0.1:1099 which is the default port for rmi?
ASKER
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.
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.
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...
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...
ASKER
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.
127.0.0.1 localhost
I can also ping localhost and it returns 127.0.0.1.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Ashishagarwal,
Thanks for your help. It still doesn't seem to work, but I'll have a look at the samples from JDK.
Thanks for your help. It still doesn't seem to work, but I'll have a look at the samples from JDK.
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\
once its up!! then your application shoudl run!!
best of luck!!