Problem Description:
Today, when configuring ACTIVEMQ, the ACTIVEMQ profile was modified: <broker brokername= "localhost" false "usejmx=" xmlns= config/1.0 ">
Error when starting:
Loading message broker From:xbean:activemq.xml INFO BROKERSERVICE-ACTIVEMQ 4.1.1 JMS message broker ( localhost) is starting INFO brokerservice-for Help or more information please See:http://incubator.ap
Ache.org/activemq/info Jdbcpersistenceadapter-database Driver recognized: [Apache_derby_embedded_jdbc_driver] Info Defaultdatabaselocker-attempting to acquire the exclusive lock to become the Master broker INFO Defaultd Atabaselocker-becoming the master on datasource:org.apache.derby.jdbc.embeddeddatasource@31ca9394 INFO Journa Lpersistenceadapter-journal Recovery started from:active journal:using 5 x 20.0 megs at:/home/dhcp2/lcdmp2_web/a Pache-activemq-4.1.1/activemq-data/journal INFO journalpersistenceadapter-journal recovered:0 message (s) in trans
Actions recovered. The ERROR brokerservice-failed to start ActiveMQ the JMS message Broker. Reason:java.net.UnknownHostException:locaLhost java.net.UnknownHostException:localhost at Java.net.ResolverCache.getHostByName (LIBGCJ.SO.7RH) at Java.net.In Etaddress.getallbyname (LIBGCJ.SO.7RH) at Java.net.InetAddress.getByName (LIBGCJ.SO.7RH) at Org.apache.activemq.transport.tcp.TcpTransportServer.bind (tcptransportserver.java:76) at Org.apache.activemq.transport.tcp.TcpTransportFactory.doBind (tcptransportfactory.java:56) at Org.apache.activemq.transport.TransportFactory.bind (transportfactory.java:109) at Org.apache.activemq.broker.TransportConnector.createTransportServer (transportconnector.java:270) at Org.apache.activemq.broker.TransportConnector.getServer (transportconnector.java:122) at Org.apache.activemq.broker.TransportConnector.start (transportconnector.java:220) at Org.apache.activemq.broker.BrokerService.startTransportConnector (brokerservice.java:1519) at Org.apache.activemq.broker.BrokerService.startAllConnectors (brokerservice.java:1471) at Org.apache.activemq.broker.BrokerService.Start (brokerservice.java:402) at Org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet ( XBEANBROKERSERVICE.JAVA:47) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods ( abstractautowirecapablebeanfactory.java:1062) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1029) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:420) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:245) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:141) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean ( abstractbeanfactory.java:242) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean ( Abstractbeanfactory.java:156) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:290) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:348) at Org.apache.xbean.spring.context.classpathxmlapplicationcontext.<init > (classpathxmlapplicationcontext.java:161) at Org.apache.xbean.spring.context.ClassPathXmlApplicationContext. <init> (classpathxmlapplicationcontext.java:51) at Org.apache.activemq.xbean.XBeanBrokerFactory.createBroker (xbeanbrokerfactory.java:41) at Org.apache.activemq.broker.BrokerFactory.createBroker (brokerfactory.java:57) at Org.apache.activemq.console.command.StartCommand.startBroker (startcommand.java:82) at Org.apache.activemq.console.command.StartCommand.runTask (startcommand.java:47) at Org.apache.activemq.console.command.AbstractCommand.execute (ABSTRACTCOMMAND.JAVA:50) at Org.apache.activemq.console.command.ShellCommand.Runtask (shellcommand.java:82) at Org.apache.activemq.console.command.AbstractCommand.execute ( ABSTRACTCOMMAND.JAVA:50) at Org.apache.activemq.console.command.ShellCommand.main (shellcommand.java:46) at Java.lang.reflect.Method.invoke (LIBGCJ.SO.7RH) at Org.apache.activemq.console.Main.runTaskClass (main.java:202) at Org.apache.activemq.console.Main.main (main.java:91) ERROR:java.lang.RuntimeException:Failed to execute Start task. Reason:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [Activemq.xml]: Invocation the Init method FA iled; Nested exception is Java.net.UnknownHostException:localhost java.lang.RuntimeException:Failed to execute Start task. Reason:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [Activemq.xml]: Invocation of Init metHod failed; Nested exception is java.net.UnknownHostException:localhost at Org.apache.activemq.console.command.StartCommand.runTask (startcommand.java:70) at Org.apache.activemq.console.command.AbstractCommand.execute (ABSTRACTCOMMAND.JAVA:50) at Org.apache.activemq.console.command.ShellCommand.runTask (shellcommand.java:82) at Org.apache.activemq.console.command.AbstractCommand.execute (ABSTRACTCOMMAND.JAVA:50) at Org.apache.activemq.console.command.ShellCommand.main (shellcommand.java:46) at Java.lang.reflect.Method.invoke ( LIBGCJ.SO.7RH) at Org.apache.activemq.console.Main.runTaskClass (main.java:202) at Org.apache.activemq.console.Main . Main (main.java:91) caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [Activemq.xml]: Invocation the Init method FA iled; Nested exception is java.net.UnknownHostException:localhost at org.springframework.beAns.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (Abstractautowirecapablebeanfactory.java : 1032) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:420) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:245) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:141) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean ( abstractbeanfactory.java:242) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean ( abstractbeanfactory.java:156) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:290) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:348) at Org.apache.xbean.spring.context.ClassPathxmlapplicationcontext.<init> (classpathxmlapplicationcontext.java:161) at Org.apache.xbean.spring.context.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:51) at Org.apache.activemq.xbean.XBeanBrokerFactory.createBroker ( xbeanbrokerfactory.java:41) at Org.apache.activemq.broker.BrokerFactory.createBroker (brokerfactory.java:57) at Org.apache.activemq.console.command.StartCommand.startBroker (startcommand.java:82) at Org.apache.activemq.console.command.StartCommand.runTask (startcommand.java:47) ... 7 caused by:java.net.UnknownHostException:localhost at Java.net.ResolverCache.getHostByName (LIBGCJ.SO.7RH) at Java.net.InetAddress.getAllByName (LIBGCJ.SO.7RH) at Java.net.InetAddress.getByName (LIBGCJ.SO.7RH) at Org.apache.ac Tivemq.transport.tcp.TcpTransportServer.bind (tcptransportserver.java:76) at Org.apache.activemq.transport.tcp.TcpTransportFactory.doBind (tcptransportfactory.java:56) at Org.apache.activemq.transPort. Transportfactory.bind (transportfactory.java:109) at Org.apache.activemq.broker.TransportConnector.createTransportServer (transportconnector.java:270) at Org.apache.activemq.broker.TransportConnector.getServer (transportconnector.java:122) at Org.apache.activemq.broker.TransportConnector.start (transportconnector.java:220) at Org.apache.activemq.broker.BrokerService.startTransportConnector (brokerservice.java:1519) at Org.apache.activemq.broker.BrokerService.startAllConnectors (brokerservice.java:1471) at Org.apache.activemq.broker.BrokerService.start (brokerservice.java:402) at Org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet (xbeanbrokerservice.java:47) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods ( abstractautowirecapablebeanfactory.java:1062) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1029) ... More ERROR:java.lang.Exception:org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [Activemq.xml]: Invocation the Init method FA iled; Nested exception is Java.net.UnknownHostException:localhost java.lang.Exception: Org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [Activemq.xml]: Invocation the Init method FA iled; Nested exception is java.net.UnknownHostException:localhost at Org.apache.activemq.console.command.StartCommand.runTask (startcommand.java:71) at Org.apache.activemq.console.command.AbstractCommand.execute (ABSTRACTCOMMAND.JAVA:50) at Org.apache.activemq.console.command.ShellCommand.runTask (shellcommand.java:82) at Org.apache.activemq.console.command.AbstractCommand.execute (ABSTRACTCOMMAND.JAVA:50) at Org.apache.activemq.console.command.SheLlcommand.main (shellcommand.java:46) at Java.lang.reflect.Method.invoke (LIBGCJ.SO.7RH) at Org.apache.activemq.console.Main.runTaskClass (main.java:202) at Org.apache.activemq.console.Main.main (Main.java : caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [Activemq.xml]: Invocation the Init method FA iled; Nested exception is java.net.UnknownHostException:localhost at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1032) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:420) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:245) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (Defaultsingletonbeanregistry.java:141) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean ( abstractbeanfactory.java:242) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean ( abstractbeanfactory.java:156) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:290) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:348) at Org.apache.xbean.spring.context.classpathxmlapplicationcontext.<init > (classpathxmlapplicationcontext.java:161) at Org.apache.xbean.spring.context.ClassPathXmlApplicationContext. <init> (classpathxmlapplicationcontext.java:51) at Org.apache.activemq.xbean.XBeanBrokerFactory.createBroker (xbeanbrokerfactory.java:41) at Org.apache.activemq.broker.BrokerFactory.createBroker (brokerfactory.java:57) at Org.apache.activemq.console.command.StartCommand.startBroker (startcommand.java:82) AT Org.apache.activemq.console.command.StartCommand.runTask (startcommand.java:47) ... 7 caused by:java.net.UnknownHostException:localhost at Java.net.ResolverCache.getHostByName (LIBGCJ.SO.7RH) at Java.net.InetAddress.getAllByName (LIBGCJ.SO.7RH) at Java.net.InetAddress.getByName (LIBGCJ.SO.7RH) at Org.apache.ac Tivemq.transport.tcp.TcpTransportServer.bind (tcptransportserver.java:76) at Org.apache.activemq.transport.tcp.TcpTransportFactory.doBind (tcptransportfactory.java:56) at Org.apache.activemq.transport.TransportFactory.bind (transportfactory.java:109) at Org.apache.activemq.broker.TransportConnector.createTransportServer (transportconnector.java:270) at Org.apache.activemq.broker.TransportConnector.getServer (transportconnector.java:122) at Org.apache.activemq.broker.TransportConnector.start (transportconnector.java:220) at Org.apache.activemq.broker.BrokerService.startTransportConnector (brokerservice.java:1519) at Org.apache.activemq.broker.BrokerService.startallconnectors (brokerservice.java:1471) at Org.apache.activemq.broker.BrokerService.start ( brokerservice.java:402) at Org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet ( XBEANBROKERSERVICE.JAVA:47) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods ( abstractautowirecapablebeanfactory.java:1062) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1029) ... More info brokerservice-activemq message Broker (localhost, null) are shutting down INFO Networkcon Nector-network Connector default-nc Stopped INFO transportconnector-connector openwire Stop PED INFO BROKERSERVICE-ACTIVEMQ JMS message Broker (localhost, null) stopped
Problem Analysis:
According to the log Java.net.UnknownHostException:localhost judge, should be due to the server can not correctly resolve localhost caused by
[123@test conf]$ ping localhost
ping:unknown host localhost
[123@test conf]$ ping 127.0.0.1
ping 127.0.0.1 ( 127.0.0.1) bytes of data.
Bytes from 127.0.0.1:icmp_seq=1 ttl=64 time=0.020 ms-
bytes from 127.0.0.1:icmp_seq=2 ttl=64 time=0.026 Ms
Bytes from 127.0.0.1:icmp_seq=3 ttl=64 time=0.023 ms
Based on log error creating Bean with Name ' Org.apache.activemq.xbean.XBeanBrokerService ' defined in class path resource [ACTIVEMQ . xml] Judgment, it should be an error in the Brokerservice configuration in the Activemq.xml file
Solution Method:
One: Do not use localhost and use 127.0.0.1 instead
Two: Modifying host mappings
[Root@test test]# vi/etc/hosts
Add the following line to the open file (this is guaranteed to be the first one to start with 127.0.0.1):
127.0.0.1 localhost.localdomain localhost
The following test results show that the configuration was successful:
[Root@test test]# ping localhost
ping localhost.localdomain (127.0.0.1) bytes of data.
Bytes from Localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.019 ms-bytes from
localhost.localdomain ( 127.0.0.1): icmp_seq=2 ttl=64 time=0.020 ms bytes from
localhost.localdomain 127.0.0.1 (icmp_seq=3): ttl=64 time=0 024 Ms
bytes from Localhost.localdomain (127.0.0.1): icmp_seq=4 ttl=64-time=0.020 ms bytes from
LOCALHOST.L Ocaldomain (127.0.0.1): icmp_seq=5 ttl=64 time=0.018 ms
---localhost.localdomain ping statistics---
5 packets t Ransmitted, 5 received, 0% packet loss, time 4009ms
RTT Min/avg/max/mdev = 0.018/0.020/0.024/0.003 ms
You can use localhost in the configuration file at this time, and the server resolves localhost to 127.0.0.1