Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.rmi.ConnectException  RSS feed

 
sunny dhoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I work in testing in a product dev co.

we have webapp and use client server architecture for testing

we use apache/tomcat as the web server/servlet engine

Everytime we face the following exception in our server

java.rmi.ConnectException: Connection refused to host: i3370.ptcnet.ptc.com; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
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:306)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at wt.manager.RemoteServerManager.getServerManager(RemoteServerManager.java:753)
at wt.manager.RemoteServerManager.getServer(RemoteServerManager.java:295)
at wt.manager.RemoteServerManager.getServer(RemoteServerManager.java:268)



Could anyone please suggest the cause and solution for this?


Thanks
 
Abhinit Saxena
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure but it looks like your server/container is not able to listen the port. It is possible that any other service is already running on the port to which you configure to listen. Please check

Thanks
Abhinit
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sleeper31,

Please have a look at the Javaranch's naming policy.

I guess if some server is already running in that particular port and in the same machine then you should be able to connect.

Are you sure that server is running in that machine and at the specified port ?

Quick test : do a telnet to that machine and that port and see whether you are able to establish a successful connection or not.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sleeper31",

Please check you private messages.
 
sunny dhoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks all for your solution

yes. the server is running on that port on the same machine to which we are trying to connect through a client. i checked it.

may be some other service was running on same port.

but i could not get how more than one services can run on same machine on same port.

Does apache web servers generate daemons (backgrnd processes) especially on unix. because i noticed that even after stopping apache, httpd processes keep on running that we need to kill explicitly (using kill command in unix or using the process explorer on windows)

also many a times we face bind exception. can someone explain why bind exception happens and how to get rid of it without stopping the application.

it would be great if smone can clarify the three states of a port,

TIME_WAIT
ESTABLISHED
LISTEN

(output we get from netstat command)
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sunny dh:
may be some other service was running on same port.


Two servers programs cannot listen to one port at the same time.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sunny dh", please check your email for an important message from me.
 
sunny dhoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Bhattacharjee:

Two servers programs cannot listen to one port at the same time.


Yes. I agree. I did not say two server programs are running on same port. I am asking, What is the real cause of ConnectException? Why do we face it?

Could someone please explain in detail?

Also could you please answer the question in my previous post.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sunny dhoni:
Originally posted by Rahul Bhattacharjee:
Could someone please explain in detail?
Also could you please answer the question in my previous post.


I guess there might be couple of thing that might result in this.Say nothing is running in the specified port or network problem.

ESTABLISHED - Already a TCP connection is established and the channel has been established.

LISTEN - Listening for requests.
 
sunny dhoni
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
so ESTABLISHED means connection is established with the service running on that port.
and LISTEN means the port is ready to listen for the requests that will be taken care by the service that is running.
and let me guess TIME_WAIT. it means already a request is being served on that port and any other incoming request would have to wait for being served.
Now considering all above definitions, ConnectException is faced when we don't have any service running on that particular port to serve the incoming request and so the client is not able to connect to the service.
Is whatever I said above is right?
But I have checked using telnet <host> <port> command and I found that the service is running but still the client is not able to connect to the service (Apache in this case) and hence throws ConnectException.
Why is it so?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sunny dhoni:
I found that the service is running but still the client is not able to connect to the service (Apache in this case) and hence throws ConnectException.


The best thing to check this would be to check the logs of the server.If the information in logs isn't enough then try running the server again with changes in the configuration so that it gives maximum information in log.I am sure there is some way it would be logging these situation in case of errors.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!