我正在尝试首次设置Apache ActiveMQ

我发现服务器名称中带有下划线,这阻止了ActiveMQ的启动。它抛出此异常:



在哪里可以在配置中设置主机名。该服务器具有其他别名,但不带下划线,否则我可以使用IP地址。服务器名称cms_delta.mycompany.com是自动获取的。

除了brokerName之外,我在activemq.xml中看不到任何明显的东西,但这不能解决问题。

这是完整的日志:

 2013-11-14 14:30:02,347 | INFO  | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@54520eb: startup date [Thu Nov 14 14:30:02 PST 2013]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main
 2013-11-14 14:30:04,100 | INFO  | PListStore:[/opt/apache-activemq-5.9.0/data/esb-dev.mycompany.com/tmp_storage] started | org.apache.activemq.store.kahadb.plist.PListStoreImpl | main
 2013-11-14 14:30:04,154 | INFO  | Using Persistence Adapter: KahaDBPersistenceAdapter[/opt/apache-activemq-5.9.0/data/kahadb] | org.apache.activemq.broker.BrokerService | main
 2013-11-14 14:30:04,475 | INFO  | Persistence store purged. | org.apache.activemq.store.kahadb.MessageDatabase | main
 2013-11-14 14:30:04,678 | INFO  | Apache ActiveMQ 5.9.0 (esb-dev.mycompany.com, ID:cms_delta.mycompany.com-35039-1384468204550-0:1) is starting | org.apache.activemq.broker.BrokerService | main
 2013-11-14 14:30:04,697 | INFO  | Listening for connections at: tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 | org.apache.activemq.transport.TransportServerThreadSupport | main
 2013-11-14 14:30:04,699 | INFO  | Connector openwire started | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:04,704 | INFO  | Listening for connections at: amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600 | org.apache.activemq.transport.TransportServerThreadSupport | main
 2013-11-14 14:30:04,707 | INFO  | Connector amqp started | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:04,712 | INFO  | Listening for connections at: stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600 | org.apache.activemq.transport.TransportServerThreadSupport | main
 2013-11-14 14:30:04,734 | INFO  | Connector stomp started | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:04,738 | INFO  | Listening for connections at: mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600 | org.apache.activemq.transport.TransportServerThreadSupport | main
 2013-11-14 14:30:04,739 | INFO  | Connector mqtt started | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:04,853 | ERROR | Failed to start Apache ActiveMQ ([esb-dev.mycompany.com, ID:cms_delta.mycompany.com-35039-1384468204550-0:1], java.net.URISyntaxException: Illegal character in hostname at index 8: ws://cms_delta.mycompany.com:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600) | org.apache.activemq.broker.BrokerService | main
 2013-11-14 14:30:04,854 | INFO  | Apache ActiveMQ 5.9.0 (esb-dev.mycompany.com, ID:cms_delta.mycompany.com-35039-1384468204550-0:1) is shutting down | org.apache.activemq.broker.BrokerService | main
 2013-11-14 14:30:06,705 | INFO  | Connector openwire stopped | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:06,708 | INFO  | Connector amqp stopped | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:06,737 | INFO  | Connector stomp stopped | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:06,748 | INFO  | Connector mqtt stopped | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:06,749 | INFO  | Connector ws stopped | org.apache.activemq.broker.TransportConnector | main
 2013-11-14 14:30:06,752 | INFO  | PListStore:[/opt/apache-activemq-5.9.0/data/esb-dev.mycompany.com/tmp_storage] stopped | org.apache.activemq.store.kahadb.plist.PListStoreImpl | main
 2013-11-14 14:30:06,752 | INFO  | Stopping async queue tasks | org.apache.activemq.store.kahadb.KahaDBStore | main
 2013-11-14 14:30:06,753 | INFO  | Stopping async topic tasks | org.apache.activemq.store.kahadb.KahaDBStore | main
 2013-11-14 14:30:06,754 | INFO  | Stopped KahaDB | org.apache.activemq.store.kahadb.KahaDBStore | main
 2013-11-14 14:30:07,045 | INFO  | Apache ActiveMQ 5.9.0 (esb-dev.mycompany.com, ID:cms_delta.mycompany.com-35039-1384468204550-0:1) uptime 2.939 seconds | org.apache.activemq.broker.BrokerService | main
 2013-11-14 14:30:07,046 | INFO  | Apache ActiveMQ 5.9.0 (esb-dev.mycompany.com, ID:cms_delta.mycompany.com-35039-1384468204550-0:1) is shutdown | org.apache.activemq.broker.BrokerService | main
 2013-11-14 14:30:07,047 | INFO  | Closing org.apache.activemq.xbean.XBeanBrokerFactory$1@54520eb: startup date [Thu Nov 14 14:30:02 PST 2013]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main
 2013-11-14 14:30:07,050 | WARN  | Exception thrown from LifecycleProcessor on context close | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main
 java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.apache.activemq.xbean.XBeanBrokerFactory$1@54520eb: startup date [Thu Nov 14 14:30:02 PST 2013]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
    at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.java:30)
    at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:782)
    at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.java:122)
    at org.apache.activemq.broker.BrokerService.start(BrokerService.java:574)
    at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:73)
    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.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1608)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1549)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
    at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
    at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(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:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
    at org.apache.activemq.console.Main.main(Main.java:115)

最佳答案

我在PC上运行ActiveMQ时遇到了同样的问题。

要更改ActiveMQ使用的名称,您应该进入/conf/activemq.xml文件,并将0.0.0.0 transportConnectors/transportConnector属性中的uri替换为您的IP地址,即127.0.0.1。它应该看起来像:

<transportConnectors>
    <transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    ...
</transportConnectors>

现在,您应该转到hosts文件,并将一些域映射添加到本地计算机。
在我的情况下(Windows 7),该文件位于C:\Windows\System32\drivers\etc\下。
我添加的行是
127.0.0.1                   mydomain.com

然后,在运行ActiveMQ时,您应该看到以下行:



ActiveMQ将启动。

关于java - 在哪里可以手动配置ActiveMQ主机名?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19990718/

10-13 03:01