Search code examples
javaexceptionjbossaxisi2b2

Two instances of same application on JBoss throws this exception: java.lang.Exception: Port 8083 already in use


On a Windows Server 2008 box, I'm trying to run two instances of the same application. This application (i2b2) is using Apache Axis 2 web services. The JAX-WS web services are running on port 9090, and are calling our application source code in JBoss on port 8083. I made a complete copy of the application code (which includes the Apache Axis 2 extracted war file) to avoid confusion, and changed the port connection for our web services on the second instance from 9090 to 9091 in {jboss folder}\server\default\deploy\jboss-webdeployer\server.xml.

I might be going about this the wrong way. I'm not so concerned with running on different ports, I just need to have two instances. So if making a copy of the application compiled source code and switching ports is not the best way to go about this, let me if you have a different idea.

<Connector port="9091" address="${jboss.bind.address}"    
     maxThreads="250" maxHttpHeaderSize="8192"
     emptySessionPath="true" protocol="HTTP/1.1"
     enableLookups="false" redirectPort="8443" acceptCount="100"
     connectionTimeout="20000" disableUploadTimeout="true" />

After starting JBoss, with this command from the JBoss bin folder, I get the exception below. See more details on places I found port 8083 referenced.

run -b 0.0.0.0 > debug.txt

Exception:

14:39:04,011 INFO  [Server] Starting JBoss (MX MicroKernel)...
14:39:04,011 INFO  [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)
14:39:04,011 INFO  [Server] Home Dir: C:\i2b2\jboss-4.2.2.GA - QA
14:39:04,011 INFO  [Server] Home URL: file:/C:/i2b2/jboss-4.2.2.GA - QA/
14:39:04,011 INFO  [Server] Patch URL: null
14:39:04,011 INFO  [Server] Server Name: default
14:39:04,011 INFO  [Server] Server Home Dir: C:\i2b2\jboss-4.2.2.GA - QA\server\default
14:39:04,011 INFO  [Server] Server Home URL: file:/C:/i2b2/jboss-4.2.2.GA - QA/server/default/
14:39:04,011 INFO  [Server] Server Log Dir: C:\i2b2\jboss-4.2.2.GA - QA\server\default\log
14:39:04,011 INFO  [Server] Server Temp Dir: C:\i2b2\jboss-4.2.2.GA - QA\server\default\tmp
14:39:04,011 INFO  [Server] Root Deployment Filename: jboss-service.xml
14:39:04,395 INFO  [ServerInfo] Java version: 1.6.0_26,Sun Microsystems Inc.
14:39:04,395 INFO  [ServerInfo] Java VM: Java HotSpot(TM) 64-Bit Server VM 20.1-b02,Sun Microsystems Inc.
14:39:04,396 INFO  [ServerInfo] OS-System: Windows Server 2008 6.0,amd64
14:39:06,280 INFO  [Server] Core system initialized
14:39:07,778 INFO  [WebService] Using RMI server codebase: http://dev-himci2b2:8083/
14:39:07,779 INFO  [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
14:39:07,893 WARN  [ServiceController] Problem starting service jboss:service=WebService
java.lang.Exception: Port 8083 already in use.
    at org.jboss.web.WebServer.start(WebServer.java:233)
    at org.jboss.web.WebService.startService(WebService.java:322)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at org.jboss.system.ServiceController.start(ServiceController.java:435)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:508)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.BindException: Address already in use: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
    at java.net.ServerSocket.bind(ServerSocket.java:328)
    at java.net.ServerSocket.<init>(ServerSocket.java:194)
    at org.jboss.web.WebServer.start(WebServer.java:226)
    ... 50 more
14:39:07,919 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: JVM_Bind
    at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:310)
    at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218)
    at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)

Here is where I found port 8083 referenced. I tried changing it to port 8084, but it still seems to look for port 8083.

jboss-4.2.2.GA\server\all\conf\jboss-service.xml

Source code for jboss-service.xml:

   <!-- ==================================================================== -->
   <!-- Class Loading                                                        -->
   <!-- ==================================================================== -->

   <!-- A mini webserver used for dynamic and class and resource loading --> 
   <mbean code="org.jboss.web.WebService"
      name="jboss:service=WebService">
      <!-- The Bind address and Port -->
      <attribute name="BindAddress">${jboss.bind.address}</attribute>      
      <attribute name="Port">8083</attribute>
      <!--  The address to use for the host portion of the RMI codebase URL -->
      <attribute name="Host">${java.rmi.server.hostname}</attribute>
      <!-- Should non-EJB .class files be downloadable -->
      <attribute name="DownloadServerClasses">true</attribute>
      <!-- Should resources other than .class files be downloadable. Both
         DownloadServerClasses and DownloadResources must be true for resources
         to be downloadable. This is false by default because its generally a
         bad idea as server configuration files that container security
         information can be accessed.
       -->
      <attribute name="DownloadResources">false</attribute>

      <!-- Use the default thread pool for dynamic class loading -->
      <depends optional-attribute-name="ThreadPool"
         proxy-type="attribute">jboss.system:service=ThreadPool</depends>
   </mbean>

EDIT @ 4:20pm on 3/18/2013:

Updated this port to 8084:

\jboss-4.2.2.GA\server\default\conf\jboss-service.xml

Source code:

   <!-- ==================================================================== -->
   <!-- Class Loading                                                        -->
   <!-- ==================================================================== -->

   <!-- A mini webserver used for dynamic and class and resource loading --> 
   <mbean code="org.jboss.web.WebService"
      name="jboss:service=WebService">
      <!-- The Bind address and Port -->
      <attribute name="BindAddress">${jboss.bind.address}</attribute>      
      <attribute name="Port">8084</attribute>
      <!--  The address to use for the host portion of the RMI codebase URL -->
      <attribute name="Host">${java.rmi.server.hostname}</attribute>
      <!-- Should non-EJB .class files be downloadable -->
      <attribute name="DownloadServerClasses">true</attribute>
      <!-- Should resources other than .class files be downloadable. Both
         DownloadServerClasses and DownloadResources must be true for resources
         to be downloadable. This is false by default because its generally a
         bad idea as server configuration files that container security
         information can be accessed.
       -->
      <attribute name="DownloadResources">false</attribute>

      <!-- Use the default thread pool for dynamic class loading -->
      <depends optional-attribute-name="ThreadPool"
         proxy-type="attribute">jboss.system:service=ThreadPool</depends>
   </mbean>

And now I get this exception:

16:19:49,473 INFO  [Server] Starting JBoss (MX MicroKernel)...
16:19:49,475 INFO  [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)
16:19:49,475 INFO  [Server] Home Dir: C:\i2b2\jboss-4.2.2.GA - QA
16:19:49,475 INFO  [Server] Home URL: file:/C:/i2b2/jboss-4.2.2.GA - QA/
16:19:49,476 INFO  [Server] Patch URL: null
16:19:49,476 INFO  [Server] Server Name: default
16:19:49,476 INFO  [Server] Server Home Dir: C:\i2b2\jboss-4.2.2.GA - QA\server\default
16:19:49,476 INFO  [Server] Server Home URL: file:/C:/i2b2/jboss-4.2.2.GA - QA/server/default/
16:19:49,476 INFO  [Server] Server Log Dir: C:\i2b2\jboss-4.2.2.GA - QA\server\default\log
16:19:49,476 INFO  [Server] Server Temp Dir: C:\i2b2\jboss-4.2.2.GA - QA\server\default\tmp
16:19:49,477 INFO  [Server] Root Deployment Filename: jboss-service.xml
16:19:49,642 INFO  [ServerInfo] Java version: 1.6.0_26,Sun Microsystems Inc.
16:19:49,643 INFO  [ServerInfo] Java VM: Java HotSpot(TM) 64-Bit Server VM 20.1-b02,Sun Microsystems Inc.
16:19:49,643 INFO  [ServerInfo] OS-System: Windows Server 2008 6.0,amd64
16:19:49,871 INFO  [Server] Core system initialized
16:19:51,393 INFO  [WebService] Using RMI server codebase: http://dev-himci2b2:8084/
16:19:51,395 INFO  [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
16:19:51,546 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: JVM_Bind
    at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:310)
    at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218)
    at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
    at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
    at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:190)
    at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
    at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:256)
    at org.jnp.server.Main.initJnpInvoker(Main.java:354)
    at org.jnp.server.Main.start(Main.java:316)
    at org.jboss.naming.NamingService.startService(NamingService.java:284)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at org.jboss.system.ServiceController.start(ServiceController.java:435)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:508)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.BindException: Address already in use: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
    at java.net.ServerSocket.bind(ServerSocket.java:328)
    at java.net.ServerSocket.<init>(ServerSocket.java:194)
    at org.jboss.net.sockets.DefaultSocketFactory.createServerSocket(DefaultSocketFactory.java:120)
    at org.jboss.net.sockets.DefaultSocketFactory.createServerSocket(DefaultSocketFactory.java:95)
    at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:649)
    at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:299)
    ... 61 more
16:19:51,594 INFO  [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
16:19:51,594 INFO  [TransactionManagerService] Setting up property manager MBean and JMX layer

EDIT 6:35pm on 3/18/2013:

These were the best instructions. http://darrellgrainger.blogspot.com/2010/02/changing-ports-in-jboss.html ...

Good news ... is that I was able to un-comment out that JBoss port-01 section in the xml file by moving the --> before the XML tag. I then made a copy of the jboss\default\ folder and renamed it default-qa. So the second instance of JBoss should be using port 8183 now. port-default for the folder default should still be bound to port 8083 by default. And started up the second instance of JBoss just fine by doing this from the jboss bin folder run -b 0.0.0.0 -c default-qa > debug-qa.txt. That worked fine.

Bad news ... The application code has ${jboss.home}/server/default/deploy/ hard coded, and the Apache Axis 2 port set in the Spring Web Framework *.properties file(s) to 9090 everywhere. Since the second instance of JBoss is relying on Apache Axis 9091, I'm thinking I need to make another copy of the source code and use port 9091 now, and just keep the same folder structure in the second instance, but move the root folder somewhere else. Then recompile.


Solution

  • If you want to run two JBoss instances on the same machine you should change ports bidning (see e.g. for JBoss 4.X How to run multiple instances of JBoss in a one single machine?. Note that for every JBoss version this is configured differently (see this).

    It can also happen that some other program took required port. Two most often offenders are MS Outlook and Skype. To check this run:

    netstat -a -o
    

    which would give you a list of occupied ports and process id. You can check in task manager which program is using a given port and, possibly, kill it.