DebugBindException

Debugging bind exceptions

 

BindExceptions indicate another process already has the interface/port combination jboss is trying to use in use. This example shows that naming service 1098 port is already in use.

20:54:40,859 WARN  [ServiceController] Problem starting service jboss:service=Naming
java.rmi.server.ExportException: Port already in use: 1098; nested exception is: 
        java.net.BindException: Address already in use
        at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:243)
        at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:178)
        at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:382)
        at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:116)

 

Note: this can occur on Windows machines as prior to Windows Vista/2008 Server the IANA standards were not adhered to. Windows can grab ports between 1025 and 5000 for it's own use - see http://support.microsoft.com/kb/929851

 

Finding the process using the port/address on Win32

Use the TCPView utility from sysinternals to list the process port usage:

http://technet.microsoft.com/en-gb/sysinternals/bb897437.aspx

 

The netstat command on WindowsXP, Server2003+ also support a -o option which displays the owning process ID associated with each connection.

 

Reserving Ports on Win32

You can reserve a range of ephemeral ports so that only processes that

specifically request a port in the reserved range can use it. Ephemeral (short-lived) port numbers start at 1024. To reserve one or more ranges of ephemeral ports:

 

  1. Use Regedt32.exe to navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

  2. On the Edit menu, Add Value name ReservedPorts as a REG_MULTI_SZ Data Type.

  3. For each range that you wish to add, type a line in the Multi-String Editor dialog, using the FFFF-TTTT syntax, where FFFF is the starting port of the range and TTTT is the ending port of the range. If only one port exists in the range, FFFF and TTTT are identical.

 

See MSKB 812873 for more information.

 

See UsingJBossBehindAFirewall for the typical ports jboss uses. A range of 1098-8093 certainly covers the default port usage for jboss.

 

Finding the process using the port/address on nix

On linux you can use netstat with the -p argument or the lsof tool to find the process using the port in question.

 

Reserving Ports on nix

You can assign ports to applications that request random ports. This can be done by assigning explicit port numbers in /etc/services to those applications that request random ports. This way random port allocations can be avoided and the ports needed by JBoss instances can be freed.

 

Referenced by: