Thursday 5 February 2015

Cannot run ActiveMQ to listen on port 61614 (or any other ports)? Create the activemq-data/localhost/ directory

Check the ActiveMQ log:
# tail /var/log/activemq/activemq.log
2015-02-04 12:04:42,929 [main           ] INFO  SharedFileLocker               - Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: Failed to create directory 'activemq-data/localhost/KahaDB'
2015-02-04 12:04:52,929 [main           ] INFO  SharedFileLocker               - Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: Failed to create directory 'activemq-data/localhost/KahaDB'
2015-02-04 12:05:02,931 [main           ] INFO  SharedFileLocker               - Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: Failed to create directory 'activemq-data/localhost/KahaDB'
2015-02-04 12:05:12,932 [main           ] INFO  SharedFileLocker               - Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: Failed to create directory 'activemq-data/localhost/KahaDB'
2015-02-04 12:05:22,933 [main           ] INFO  SharedFileLocker               - Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: Failed to create directory 'activemq-data/localhost/KahaDB'
2015-02-04 12:05:34,208 [main           ] INFO  XBeanBrokerFactory$1           - Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@6bf28508: startup date [Wed Feb 04 12:05:34 GMT 2015]; root of context hierarchy
2015-02-04 12:05:35,332 [main           ] INFO  PListStoreImpl                 - PListStore:[/usr/share/activemq/activemq-data/localhost/tmp_storage] started
2015-02-04 12:05:35,466 [main           ] INFO  BrokerService                  - Using Persistence Adapter: KahaDBPersistenceAdapter[/usr/share/activemq/activemq-data/localhost/KahaDB]
2015-02-04 12:05:35,467 [JMX connector  ] INFO  ManagementContext              - JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
2015-02-04 12:05:35,468 [main           ] INFO  SharedFileLocker               - Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: Failed to create directory 'activemq-data/localhost/KahaDB'
There's no 'activemq-data' or 'activemq-data/localhost' or 'activemq-data/localhost/KahaDB', so create it:
# mkdir -p /usr/share/activemq/activemq-data/localhost/
# chown -R activemq:activemq /usr/share/activemq/activemq-data/localhost/
# service activemq restart
Look at the logs again, use lsof on the port:
# tail /var/log/activemq/activemq.log
2015-02-04 12:08:22,850 [main           ] INFO  ndingBeanNameUrlHandlerMapping - Mapped URL path [/moveMessage.action] onto handler '/moveMessage.action'
2015-02-04 12:08:22,850 [main           ] INFO  ndingBeanNameUrlHandlerMapping - Mapped URL path [/deleteJob.action] onto handler '/deleteJob.action'
2015-02-04 12:08:22,955 [main           ] INFO  WebAppContext                  - ActiveMQ Console at http://0.0.0.0:8161/admin
2015-02-04 12:08:22,968 [main           ] INFO  ContextHandler                 - started o.e.j.w.WebAppContext{/camel,file:/var/lib/activemq/webapps/camel}
2015-02-04 12:08:22,973 [main           ] INFO  WebAppContext                  - WebApp@1311779403 at http://0.0.0.0:8161/camel
2015-02-04 12:08:22,986 [main           ] INFO  ContextHandler                 - started o.e.j.w.WebAppContext{/demo,file:/var/lib/activemq/webapps/demo}
2015-02-04 12:08:22,991 [main           ] INFO  WebAppContext                  - WebApp@1311779403 at http://0.0.0.0:8161/demo
2015-02-04 12:08:23,003 [main           ] INFO  ContextHandler                 - started o.e.j.w.WebAppContext{/fileserver,file:/var/lib/activemq/webapps/fileserver}
2015-02-04 12:08:23,008 [main           ] INFO  WebAppContext                  - WebApp@1311779403 at http://0.0.0.0:8161/fileserver
2015-02-04 12:08:23,024 [main           ] INFO  AbstractConnector              - Started SelectChannelConnector@0.0.0.0:8161


# lsof -i:61614
COMMAND   PID     USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    48120 activemq  132u  IPv6 49240809      0t0  TCP *:61614 (LISTEN)