title: Port binding exception starting activemq
body: <p>I am trying to start activeMq using the command</p>
  
  <pre><code>activemq.bat start
  </code></pre>
  
  <p>However using this command stops active MQ; which looks like the cause is port is not available. Here is the error snippet:</p>
  
  <pre><code> INFO | Apache ActiveMQ 5.10.0 (localhost, ID:LT7634-51673-1426517344431-0:1) is starting
  ERROR | Failed to start Apache ActiveMQ ([localhost, ID:LT7634-51673-1426517344431-0:1], java.io.IOException: Transport Connector could not
  be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600 due to:
   java.net.BindException: Address already in use: JVM_Bind)
   INFO | Apache ActiveMQ 5.10.0 (localhost, ID:LT7634-51673-1426517344431-0:1) is shutting down
  </code></pre>
  
  <p>However; I have verified that the port 61616 is actually not being used by any other program. I did this by doing the following in a command prompt:</p>
  
  <pre><code>netstat -aon | findstr "61616"
  </code></pre>
  
  <p>I am unable to isolate what could have caused this.
  Is there any other way to find issues that might be causing this? I also checked activemq.log; which pretty much shows the same logs as in the console.</p>
  
  <p>Things that I have tried and does not work:
  1. Tried restarting the system.</p>
  
  <ol start="2">
  <li><p>tried to find processes that has activemq, amq or apache using netsta -aon command. Found nothing.</p></li>
  <li><p>Tried deleting the kahadb folder under %ACTIVEMQ_HOME%\data folder. The folder gets recreated.</p></li>
  </ol>
  
  <p>Adding the complete console output </p>
  
  <pre><code>D:\DevProgs\Dumps\Apache\Activemq-5.10.0\bin&gt;activemq.bat start
  Java Runtime: Oracle Corporation 1.7.0_60 D:\DevProgs\Installed\JAVA\JDKs\jdk1.7.0_60\jre
    Heap sizes: current=1005568k  free=989808k  max=1005568k
      JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.con
  fig=D:\DevProgs\Dumps\Apache\Activemq-5.10.0\conf\login.config -Dactivemq.classpath=D:\DevProgs\Dumps\Apache\Activemq-5.10.0\conf;D:\DevProg
  s\Dumps\Apache\Activemq-5.10.0/conf;D:\DevProgs\Dumps\Apache\Activemq-5.10.0/conf; -Dactivemq.home=D:\DevProgs\Dumps\Apache\Activemq-5.10.0
  -Dactivemq.base=D:\DevProgs\Dumps\Apache\Activemq-5.10.0 -Dactivemq.conf=D:\DevProgs\Dumps\Apache\Activemq-5.10.0\conf -Dactivemq.data=D:\De
  vProgs\Dumps\Apache\Activemq-5.10.0\data -Djava.io.tmpdir=D:\DevProgs\Dumps\Apache\Activemq-5.10.0\data\tmp
  Extensions classpath:
    [D:\DevProgs\Dumps\Apache\Activemq-5.10.0\lib,D:\DevProgs\Dumps\Apache\Activemq-5.10.0\lib\camel,D:\DevProgs\Dumps\Apache\Activemq-5.10.0\
  lib\optional,D:\DevProgs\Dumps\Apache\Activemq-5.10.0\lib\web,D:\DevProgs\Dumps\Apache\Activemq-5.10.0\lib\extra]
  ACTIVEMQ_HOME: D:\DevProgs\Dumps\Apache\Activemq-5.10.0
  ACTIVEMQ_BASE: D:\DevProgs\Dumps\Apache\Activemq-5.10.0
  ACTIVEMQ_CONF: D:\DevProgs\Dumps\Apache\Activemq-5.10.0\conf
  ACTIVEMQ_DATA: D:\DevProgs\Dumps\Apache\Activemq-5.10.0\data
  Loading message broker from: xbean:activemq.xml
   INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@fa0a4ca: startup date [Mon Mar 16 21:43:44 IST 2015]; root of context hier
  archy
   INFO | PListStore:[D:\DevProgs\Dumps\Apache\Activemq-5.10.0\data\localhost\tmp_storage] started
   INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[D:\DevProgs\Dumps\Apache\Activemq-5.10.0\data\kahadb]
   INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
   INFO | KahaDB is version 5
   INFO | Recovering from the journal ...
   INFO | Recovery replayed 1 operations from the journal in 0.016 seconds.
   INFO | Apache ActiveMQ 5.10.0 (localhost, ID:LT7634-52369-1426522426222-0:1) is starting
  ERROR | Failed to start Apache ActiveMQ ([localhost, ID:LT7634-52369-1426522426222-0:1], java.io.IOException: Transport Connector could not
  be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600 due to:
   java.net.BindException: Address already in use: JVM_Bind)
   INFO | Apache ActiveMQ 5.10.0 (localhost, ID:LT7634-52369-1426522426222-0:1) is shutting down
   INFO | Connector openwire stopped
   INFO | Connector amqp stopped
   INFO | Connector stomp stopped
   INFO | Connector mqtt stopped
   INFO | Connector ws stopped
   INFO | PListStore:[D:\DevProgs\Dumps\Apache\Activemq-5.10.0\data\localhost\tmp_storage] stopped
   INFO | Stopping async queue tasks
   INFO | Stopping async topic tasks
   INFO | Stopped KahaDB
   INFO | Apache ActiveMQ 5.10.0 (localhost, ID:LT7634-52369-1426522426222-0:1) uptime 0.969 seconds
   INFO | Apache ActiveMQ 5.10.0 (localhost, ID:LT7634-52369-1426522426222-0:1) is shutdown
   INFO | Closing org.apache.activemq.xbean.XBeanBrokerFactory$1@fa0a4ca: startup date [Mon Mar 16 21:43:44 IST 2015]; root of context hierarc
  hy
   WARN | Exception thrown from LifecycleProcessor on context close
  java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.
  apache.activemq.xbean.XBeanBrokerFactory$1@fa0a4ca: startup date [Mon Mar 16 21:43:44 IST 2015]; root of context hierarchy
          at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)[spring-
  context-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)[spring-context-3.2.8
  .RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)[spring-context-3.2.8.R
  ELEASE.jar:3.2.8.RELEASE]
          at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.java:30)[activemq-spring-5.10.0.jar:5.10.0]
          at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:809)[activemq-broker-5.10.0.jar:5.10.0]
          at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.java:122)[activemq-spring-5.10.0.jar:5.10.0]
          at org.apache.activemq.broker.BrokerService.start(BrokerService.java:601)[activemq-broker-5.10.0.jar:5.10.0]
          at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:73)[activemq-spring-5.10.0.jar:5.10.0]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_60]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_60]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_60]
          at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_60]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFa
  ctory.java:1638)[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory
  .java:1579)[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.ja
  va:1509)[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java
  :521)[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:4
  58)[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)[spring-beans-3.2.8.RELEAS
  E.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[spring
  -beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)[spring-beans-3.2.8.RELEASE.
  jar:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[spring-beans-3.2.8.RELEASE.ja
  r:3.2.8.RELEASE]
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628
  )[spring-beans-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:93
  2)[spring-context-3.2.8.RELEASE.jar:3.2.8.RELEASE]
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)[spring-context-3.2.8.
  RELEASE.jar:3.2.8.RELEASE]
          at org.apache.xbean.spring.context.ResourceXmlApplicationContext.&lt;init&gt;(ResourceXmlApplicationContext.java:64)[xbean-spring-3.16.jar
  :3.16]
          at org.apache.xbean.spring.context.ResourceXmlApplicationContext.&lt;init&gt;(ResourceXmlApplicationContext.java:52)[xbean-spring-3.16.jar
  :3.16]
          at org.apache.activemq.xbean.XBeanBrokerFactory$1.&lt;init&gt;(XBeanBrokerFactory.java:104)[activemq-spring-5.10.0.jar:5.10.0]
          at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104)[activemq-spring-5.10.0.jar:5.1
  0.0]
          at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67)[activemq-spring-5.10.0.jar:5.10.0]
          at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)[activemq-broker-5.10.0.jar:5.10.0]
          at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)[activemq-broker-5.10.0.jar:5.10.0]
          at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87)[activemq-console-5.10.0.jar:5.10.0]
          at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)[activemq-console-5.10.0.jar:5.10.0]
          at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)[activemq-console-5.10.0.jar:5.10.0]
          at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)[activemq-console-5.10.0.jar:5.10.0]
          at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)[activemq-console-5.10.0.jar:5.10.0]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_60]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_60]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_60]
          at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_60]
          at org.apache.activemq.console.Main.runTaskClass(Main.java:262)[activemq.jar:5.10.0]
          at org.apache.activemq.console.Main.main(Main.java:115)[activemq.jar:5.10.0]
  ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.IllegalStateException: BeanFactory not initialized or alr
  eady closed - call 'refresh' before accessing beans via the ApplicationContext
  java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.IllegalStateException: BeanFactory not initialized or already cl
  osed - call 'refresh' before accessing beans via the ApplicationContext
          at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:91)
          at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
          at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)
          at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
          at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
          at org.apache.activemq.console.Main.main(Main.java:115)
  Caused by: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Ap
  plicationContext
          at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.ja
  va:171)
          at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:487)
          at org.apache.xbean.spring.context.ResourceXmlApplicationContext.&lt;init&gt;(ResourceXmlApplicationContext.java:64)
          at org.apache.xbean.spring.context.ResourceXmlApplicationContext.&lt;init&gt;(ResourceXmlApplicationContext.java:52)
          at org.apache.activemq.xbean.XBeanBrokerFactory$1.&lt;init&gt;(XBeanBrokerFactory.java:104)
          at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104)
          at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67)
          at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
          at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
          at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87)
          ... 10 more
  ERROR: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Applic
  ationContext
  java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationCo
  ntext
          at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.ja
  va:171)
          at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:487)
          at org.apache.xbean.spring.context.ResourceXmlApplicationContext.&lt;init&gt;(ResourceXmlApplicationContext.java:64)
          at org.apache.xbean.spring.context.ResourceXmlApplicationContext.&lt;init&gt;(ResourceXmlApplicationContext.java:52)
          at org.apache.activemq.xbean.XBeanBrokerFactory$1.&lt;init&gt;(XBeanBrokerFactory.java:104)
          at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:104)
          at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:67)
          at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
          at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
          at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:87)
          at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
          at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)
          at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
          at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
          at org.apache.activemq.console.Main.main(Main.java:115)
  D:\DevProgs\Dumps\Apache\Activemq-5.10.0\bin&gt;
  </code></pre>