views:

293

answers:

5

Some times whenever I restart the application, which is built on Java Struts Mysql and Jboss 4.05 Version I get the error as Address already in use: JVM_Bind

Only fix that i know is to restart the machine and try again, it will work. Else Some times I do Ctrl-Alt-Del and Stop all the process related to Java, some times this also works.

But what is the exact reason and how can we prevent this problem ?

A: 

The quick answer on how to prevent it is that you most likely need to stop JBoss before starting it again.

You should be able to call the "Terminate" button in the Console view to shutdown the server.

Jarle Hansen
I am starting the JBoss from Eclipse
harigm
+3  A: 

Address already in use: JVM_Bind

means that some other application is already listening on the port your current application is trying to bind.

what you need to do is, either the port for your current application or better; just find out the already running application and kill it.

on linux you can find the application pid by using,

netstat -tulpn
phoenix24
How do you find that in WIndows, I am running my application on Windows
harigm
netstat works on windows too, on console try: netstat -anfor more, http://en.wikipedia.org/wiki/Netstat
phoenix24
another advice would be not to run application servers on windows.Otherwise, it might also help not to click on the restart button - but instead to stop, wait 5 seconds, and then start again manually. Sometimes java processes just need a litte time to shut down. Eg if they are busy with a db operation, they tend to keep hanging until that operation is done.
deadsven
+1  A: 

Is it possible that MySql listening on the same port as JBoss?

Is there a port number given in the error message - something like Address already in use: JVM_Bind:8080

You can change the port in JBoss server.xml to test this.

JoseK
A: 

That error means that the you are trying to create a new ServerSocket on a port already in use by another ServerSocket. So try to make your application closing all sockets and connections you know about and be sure your application is completely terminated. Also check if there is another proces you launched by your program.

Martijn Courteaux
+2  A: 

I usually come across this when the port which the server (I use JBoss) is already in use

Usual suspects

  1. Apache Http Server => turn down the service if working in windows.
  2. IIS => stop the ISS using
  3. Skype =>yea I got skype attaching itself to port 80

To change the port to which JBoss 4.2.x binds itself go to:

"C:\jboss4.2.2\server\default\deploy\jboss-web.deployer\server.xml"

here default is the instance of the server change the port here :

<Connector port="8080" address="${jboss.bind.address}" >

In the above example the port is bound to 8080

frictionlesspulley