最近真是跟activemq杠上了,今天发现又不能启动成功,然后找到以下解决办法:
Illegal character in hostname error on hosts with underscores in their host names
---------------------------------------------------------------------------------
Key: AMQ-1188
URL: https://issues.apache.org/activemq/browse/AMQ-1188
Project: ActiveMQ
Issue Type: Bug
Affects Versions: 4.1.0
Environment: RHEL4 Update 4 ES x86_64
Sun JDK 1.4.2_08
Reporter: Yanik Grignon
Priority: Minor
On a machine where the hostname contains underscores (e.g. HS_RH64_A3_1) ActiveMQ fails to initialize with the stack trace below. This seems to be a problem with the TCP protocol handler since doing new URL("<a href="http://HS_RH64_A3_1.godzilla.local:61616"" added>http://HS_RH64_A3_1.godzilla.local:61616") works fine.
2007-03-05 08:30:20,076 [WrapperSimpleAppMain] ERROR (BrokerService.java:412) - Failed to start ActiveMQ JMS Message Broker. Reason: java.io.IOException: Transp
ort Connector could not be registered in JMX: Illegal character in hostname at index 8: tcp://HS_RH64_A3_1.godzilla.local:61616
java.io.IOException: Transport Connector could not be registered in JMX: Illegal character in hostname at index 8: tcp://HS_RH64_A3_1.godzilla.local:61616
at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:25)
at org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1079)
at org.apache.activemq.broker.BrokerService.startTransportConnector(BrokerService.java:1508)
at org.apache.activemq.broker.BrokerService.startAllConnectors(BrokerService.java:1468)
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 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:585)
at org.apache.activemq.console.Main.runTaskClass(Main.java:159)
at org.apache.activemq.console.Main.main(Main.java:91)
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:585)
at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:197)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.IOException: Illegal character in hostname at index 8: tcp://HS_RH64_A3_1.godzilla.local:61616
at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:43)
at org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:94)
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.asManagedConnector(TransportConnector.java:100)
at org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1072)
... 35 more
Caused by: java.net.URISyntaxException: Illegal character in hostname at index 8: tcp://HS_RH64_A3_1.godzilla.local:61616
at java.net.URI$Parser.fail(URI.java:2816)
at java.net.URI$Parser.parseHostname(URI.java:3355)
at java.net.URI$Parser.parseServer(URI.java:3204)
at java.net.URI$Parser.parseAuthority(URI.java:3123)
at java.net.URI$Parser.parseHierarchical(URI.java:3065)
at java.net.URI$Parser.parse(URI.java:3021)
at java.net.URI.<init>(URI.java:663)
at org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:91)
... 41 more
FWIW a workaround is probably to use the IP address in the config file (its only when using the localhost that we try and resolve it).
I've added a fix to trunk to work around this where if the URI is invalid we try to use the IP address in the URI instead. Let us know if that doesn't fix it and we can reopen this issue