问题
I'm trying to set up Apache ActiveMQ for the first time
I discovered that the name of my server has an underscore in it, and that is preventing ActiveMQ from starting. It throws this exception :
java.net.URISyntaxException: Illegal character in hostname at index 8: ws://cms_delta.mycompany.com:61614? maximumConnections=1000&wireFormat.maxFrameSize=104857600) ...
Where can I set the hostname in configuration. This server has other alias names without underscores, or I could use the IP address. The servername cms_delta.mycompany.com is being fetched automatically.
I don't see anything obvious in activemq.xml other than brokerName, but that didn't fix the problem.
Here is the full log :
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)
回答1:
I have just encountered the same problem when running ActiveMQ
on my PC.
To change the name which is used by ActiveMQ
you should go into /conf/activemq.xml
file and replace 0.0.0.0
in transportConnectors/transportConnector
uri
attribute with your IP address i.e. 127.0.0.1
. It should look like:
<transportConnectors>
<transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
...
</transportConnectors>
Now you should go to hosts
file and add some domain mapping to your local machine.
In my case (Windows 7) this file is located under C:\Windows\System32\drivers\etc\
.
The line I added was
127.0.0.1 mydomain.com
Then, when running ActiveMQ you should see lines:
INFO | Listening for connections at: tcp://mydomain.com:61616?maximumConnections=1000
ActiveMQ will start.
来源:https://stackoverflow.com/questions/19990718/where-can-i-manually-configure-activemq-hostname