aspose file tools*
The moose likes Distributed Java and the fly likes Cannot Start RMI Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Cannot Start RMI Server" Watch "Cannot Start RMI Server" New topic
Author

Cannot Start RMI Server

Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

I am trying to start my run my RMI server that i have created, but seem to be unable to even start the server. I did start the rmiregistry and then attempt to start my server. Btw, i used msdos to start my rmiregistry and to start my server.

My friend has tried the coding and it works on his computer. I am thinking that it is my computer configuration but i do not know where exactly is the problem.

Here are some of the errors:

java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at addRmi.AddServerApp.main(AddServerApp.java:10)
by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Maybe caused by a blocking firewall.

Regards


SCJP, OCMJD, OCMJEA
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi Oricio Ocle ,

I have tried to disable my firewall and still it does not work.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Maybe name resolution?
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi Oricio Ocle,

What do you mean by name resolution? Do you mean i have typed the name of server wrongly? Could you describe more so i can check if it is indeed because of name resolution. Thanks

shaoen01
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

If you specifying the host name, this name must be resoluted to a IP, usually by a DNS server, or hosts file.
The answer is given pinging to the host by name.

I have just noticed these are your first post in the forum.
Welcome! and as an aditional note, you must change your nick, to conform the javaranch naming policy...

Regards
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi Oricio Ocle,

The Server Application is running on a localhost so i do not think it has anything to do with the network. I am sorry but what javaranch naming policy? How must i comply to the javaranch naming policy?
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

I've heard that
"localhost" in some linux environments could be problematic. Is it your case?

naming policy

Regards
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

I am using Windows XP Pro SP2 and not using Linux. What else do you think could be the problem? Okay, i will take a look at the naming policy. Thanks
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Windows XP comes with a buit-in firewall.
Anyway, are you running the client and the server in the same machine?
Post the code for binding and connecting...
Regards
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

I am using Windows XP Pro SP2 and not using Linux. What else do you think could be the problem? Okay, i will take a look at the naming policy. Thanks
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

I did disable windows firewall but still it did not work. Yes, i am trying to run the server and client on the same machine. But client would not work because the server can't be started.

However, when i type "start rmiregistry" it opens a new window (so i assume it should be working). And then i type "java addRmi.AddServerApp" command and that is when the error comes out.

Client App Coding


AddServerApp Coding:


AddServerImpl Coding:


P.S. I didn't mean to post twice.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Try and start the rmiregistry and then run the command "netstat -a" on the command line - make sure that the registry is running on default port 1099.

Next - are there any lines before the errors you posted before? That might help narrow some things down...

I also didn't see that you didn't say anything about a policy file... are you using one? This can cause an exception like this too...

P.S. - You need to change your display name - names cannot be obviously fake and must constist of a first name and a last name.

You can change your user name here.

Thanks! and welcome to the JavaRanch!


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

However, when i type "start rmiregistry" it opens a new window (so i assume it should be working). And then i type "java addRmi.AddServerApp" command and that is when the error comes out.


Open a DOS console and type: "rmiregistry 1099".
Then as Nathan says see if the port is listened.
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi Oricio Ocle and Nathan Pruett,

And this is the result of my netstat -a command:
TCP VALERIE-1VMVM9H:1099 VALERIE-1VMVM9H:0 LISTENING

Anything wrong here?

And i have recopied the error message again as shown below:
java.rmi.ConnectException: Connection refused to host: 192.168.1.3; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at addRmi.AddServerApp.main(AddServerApp.java:10)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
... 7 more
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

"Valerie",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

I am sorry but Valerie Pooh is my real name and is not based on a fictitious character. That name above happens to be in my birth certificate, which i think is indeed my real name. I am sorry if you thought otherwise. A lot of people has misunderstood my last name before.

[ September 11, 2006: Message edited by: Valerie Pooh ]
[ September 11, 2006: Message edited by: Valerie Pooh ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

When I made my post, your display name was shown as "Valerie" without a last name.

Thank you for adding the last name to your display name. We be cool now!

bear
JavaRanch Sheriff
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

No problem, i was afraid that people would think i am putting a fictitious last name because of my well known surname, Pooh. That's why i only put Valerie. No worries ...
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

No problems with the name - I think it would only be a problem if it was "Winnie"

Anyway, back to the RMI problems...

One thing I see that's a little strange in the error message you posted is this part: "java.rmi.ConnectException: Connection refused to host: 192.168.1.3; nested exception is:"

This looks like an actual intranet IP address, and not just 127.0.0.1 (the default loopback address). Try specifying "127.0.0.1" or "localhost" in the URL of the rebind() call.

Also, are you using a policy file? Even if it's a network problem now, not specifying a policy file to allow socket connections will cause a similiar problem later...
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi Nate,

If my name is Winnie, i think everyone will be emailing me. Haha ...

So how do i change Naming.rebind("AddServer", addServerImpl); to add the localhost? I thought that should be done (indicating the localhost) when i use my client application to call the Server side application via remote interface?

Anyway, here is my coding for the Server side Application:
aslam parveez
Ranch Hand

Joined: Apr 25, 2006
Posts: 47
Change Naming.rebind("AddServer", addServerImpl) to some thing like

Naming.rebind("rmi://localhost/AddServer",addServerImpl)
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi aslam,

I tried that and regenerated all the .class files and stub class but still it does not work. Almost similar error as above, it may be due to some network settings? Since it does even allow localhost to run, which is extremely weird.

java.rmi.ConnectException: Connection refused to host: localhost; nested excepti
on is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185
)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at addRmi.AddServerApp.main(AddServerApp.java:10)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
... 6 more
aslam parveez
Ranch Hand

Joined: Apr 25, 2006
Posts: 47
Then , it should be a problem with your TCP/IP configuration.
Type ipconfig on your command prompt and check What is the IP Address.
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi aslam,

I typed ipconfig in my command prompt and this is my ip address below. I also suspected it was my network connection problem too.

IP Address. . . . . . . . . . . . : 192.168.1.2
aslam parveez
Ranch Hand

Joined: Apr 25, 2006
Posts: 47
java.rmi.ConnectException: Connection refused to host: 192.168.1.3; nested .

In the logs you have pasted ip is recognized as 192.168.1.3
But you are saying ip is 192.168.1.2 pretty strange...
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The different IP addresses could just be due to DHCP. The IP address could differ from one run to the next if the computer has been restarted and requested a new IP address from the DHCP server...

Can you ping the IP address you get from ipconfig? Telnet to any of the open ports reported from "netstat -a"? What if you ping or telnet "localhost" and "127.0.0.1" instead of the IP reported?
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

When i try to ping 192.168.1.2 (my current ip), "Pinging 192.168.1.2 with 32 bytes of data: PING: transmit failed, error code 65."

But when i type "ping localhost" or "ping 127.0.0.1", it works perfectly fine.
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

So how do i solve this problem?
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Ping error code 65
Do you have a router?
[ September 13, 2006: Message edited by: Oricio Ocle ]
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi,

I tried to ping my own ip after i disabled my firewall. But it still gives me the same error. Any ideas on how to fix it besides the microsoft support? I tried to do whatever was mentioned but still does not work.
Valerie Pooh
Greenhorn

Joined: Sep 10, 2006
Posts: 19
Hi Guys,

I think i just want to knock myself on my head!! Apparently, it is my zonealarm that was causing the trouble. I disabled zonealarm on startup and thought that by enabling my windows firewall, my windows firewall will be controlling my computer.

But apparently, zonealarm was running in the background and i didnt even know. That's why there was a connection refused! Arghh ... hope i am making sense! Anyway, thank you so much for helping me!

I almost wanted to start pulling out my hair! Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot Start RMI Server