Java Apache ActiveMQ 在 Windows 上启动然后突然停止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21254389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 07:41:12  来源:igfitidea点击:

Apache ActiveMQ Starts then Stops Abruptly On Windows

javaactivemq

提问by Gandalf

I am running apachemq on windows xp.I have no web server services running or any database of any sort,but i keep on getting this error once i start active mq

我在 windows xp 上运行 apachemq。我没有运行 Web 服务器服务或任何类型的数据库,但是一旦我启动活动 mq,我就会不断收到此错误

ERROR | Failed to start Apache ActiveMQ ([localhost, ID:computer_1-3725-13902958 73141-0:1], java.net.URISyntaxException: Illegal character in hostname at index 13: ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857 600)

错误 | 无法启动 Apache ActiveMQ ([localhost, ID:computer_1-3725-13902958 73141-0:1], java.net.URISyntaxException: Illegal character in hostname at index 13: ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize =104857 600)

This is the complete log

这是完整的日志

C:\apache_activemq>.\bin\activemq
Java Runtime: Oracle Corporation 1.7.0_21 C:\Program Files\Java\jdk1.7.0_21\jre
  Heap sizes: current=1013632k  free=996854k  max=1013632k
    JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.c
onfig.file=logging.properties -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhaw
tio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security
.auth.login.config=C:\apache_activemq\bin\..\conf\login.config -Dactivemq.classp
ath=C:\apache_activemq\bin\..\conf;C:\apache_activemq\bin\../conf;C:\apache_acti
vemq\bin\../conf; -Dactivemq.home=C:\apache_activemq\bin\.. -Dactivemq.base=C:\a
pache_activemq\bin\.. -Dactivemq.conf=C:\apache_activemq\bin\..\conf -Dactivemq.
data=C:\apache_activemq\bin\..\data -Djava.io.tmpdir=C:\apache_activemq\bin\..\d
ata\tmp
Extensions classpath:
  [C:\apache_activemq\bin\..\lib,C:\apache_activemq\bin\..\lib\camel,C:\apache_a
ctivemq\bin\..\lib\optional,C:\apache_activemq\bin\..\lib\web,C:\apache_activemq
\bin\..\lib\extra]
ACTIVEMQ_HOME: C:\apache_activemq\bin\..
ACTIVEMQ_BASE: C:\apache_activemq\bin\..
ACTIVEMQ_CONF: C:\apache_activemq\bin\..\conf
ACTIVEMQ_DATA: C:\apache_activemq\bin\..\data
Loading message broker from: xbean:activemq.xml
 INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory@726b5b: startu
p date [Tue Jan 21 12:17:33 EAT 2014]; root of context hierarchy
 INFO | PListStore:[C:\apache_activemq\bin\..\data\localhost\tmp_storage] starte
d
 INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[C:\apache_activemq\b
in\..\data\kahadb]
 INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099
/jmxrmi
 INFO | KahaDB is version 5
 INFO | Recovering from the journal ...
 INFO | Recovery replayed 14 operations from the journal in 0.16 seconds.
 INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is starting
 INFO | Listening for connections at: tcp://0.0.0.0:61616?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
 INFO | Connector openwire started
 INFO | Listening for connections at: amqp://0.0.0.0:5672?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
 INFO | Connector amqp started
 INFO | Listening for connections at: stomp://0.0.0.0:61613?maximumConnections=1
000&wireFormat.maxFrameSize=104857600
 INFO | Connector stomp started
 INFO | Listening for connections at: mqtt://0.0.0.0:1883?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
 INFO | Connector mqtt started
ERROR | Failed to start Apache ActiveMQ ([localhost, ID:computer_1-3725-13902958
73141-0:1], java.net.URISyntaxException: Illegal character in hostname at index
13: ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857
600)
 INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is shutting down
 INFO | Connector openwire stopped
 INFO | Connector amqp stopped
 INFO | Connector stomp stopped
 INFO | Connector mqtt stopped
 INFO | Connector ws stopped
 INFO | PListStore:[C:\apache_activemq\bin\..\data\localhost\tmp_storage] stoppe
d
 INFO | Stopping async queue tasks
 INFO | Stopping async topic tasks
 INFO | Stopped KahaDB
 INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
uptime 13.059 seconds
 INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is shutdown
 INFO | Closing org.apache.activemq.xbean.XBeanBrokerFactory@726b5b: startup d
ate [Tue Jan 21 12:17:33 EAT 2014]; root of context hierarchy
 WARN | Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refr
esh' before invoking lifecycle methods via the context: org.apache.activemq.xbea
n.XBeanBrokerFactory@726b5b: startup date [Tue Jan 21 12:17:33 EAT 2014]; root
 of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getLif
ecycleProcessor(AbstractApplicationContext.java:360)
        at org.springframework.context.support.AbstractApplicationContext.doClos
e(AbstractApplicationContext.java:1057)
        at org.springframework.context.support.AbstractApplicationContext.close(
AbstractApplicationContext.java:1010)
        at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.jav
a: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(XBean
BrokerService.java:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1608)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1549)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getOb
ject(AbstractBeanFactory.java:295)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:223)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(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.finish
BeanFactoryInitialization(AbstractApplicationContext.java:932)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(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.<init>(XBeanBrokerFact
ory.java:104)
        at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
        at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
        at org.apache.activemq.console.Main.main(Main.java:115)
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: java.la
ng.IllegalStateException: BeanFactory not initialized or already closed - call '
refresh' before accessing beans via the ApplicationContext
java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.Ille
galStateException: BeanFactory not initialized or already closed - call 'refresh
' before accessing beans via the ApplicationContext
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:91)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
        at org.apache.activemq.console.Main.main(Main.java:115)
Caused by: java.lang.IllegalStateException: BeanFactory not initialized or alrea
dy closed - call 'refresh' before accessing beans via the ApplicationContext
        at org.springframework.context.support.AbstractRefreshableApplicationCon
text.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
        at org.springframework.context.support.AbstractApplicationContext.destro
yBeans(AbstractApplicationContext.java:1090)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:487)
        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.<init>(XBeanBrokerFact
ory.java:104)
        at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
        at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
        ... 10 more
ERROR: java.lang.IllegalStateException: BeanFactory not initialized or already c
losed - call 'refresh' before accessing beans via the ApplicationContext
java.lang.IllegalStateException: BeanFactory not initialized or already closed -
 call 'refresh' before accessing beans via the ApplicationContext
        at org.springframework.context.support.AbstractRefreshableApplicationCon
text.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
        at org.springframework.context.support.AbstractApplicationContext.destro
yBeans(AbstractApplicationContext.java:1090)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:487)
        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.<init>(XBeanBrokerFact
ory.java:104)
        at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
        at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
        at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
        at org.apache.activemq.console.Main.main(Main.java:115)
C:\apache_activemq>

My %SystemRoot%\system32\drivers\etc\hostslooks like this

我的%SystemRoot%\system32\drivers\etc\hosts看起来像这样

127.0.0.1 localhost

127.0.0.1 本地主机

127.0.0.1 mpa.one.microsoft.com

127.0.0.1 mpa.one.microsoft.com

My activemq.xml looks like this

我的 activemq.xml 看起来像这样

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>

    <!-- Allows log searching in hawtio console -->
    <bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery"
          lazy-init="false" scope="singleton"
          init-method="start" destroy-method="stop">
    </bean>

    <!--
        The <broker> element is used to configure the ActiveMQ broker.
    -->
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">

        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" >
                    <!-- The constantPendingMessageLimitStrategy is used to prevent
                         slow topic consumers to block producers and affect other consumers
                         by limiting the number of messages that are retained
                         For more information, see:

                         http://activemq.apache.org/slow-consumer-handling.html

                    -->
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="1000"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>


        <!--
            The managementContext is used to configure how ActiveMQ is exposed in
            JMX. By default, ActiveMQ uses the MBean server that is started by
            the JVM. For more information, see:

            http://activemq.apache.org/jmx.html
        -->
        <managementContext>
            <managementContext createConnector="true"/>
        </managementContext>

        <!--
            Configure message persistence for the broker. The default persistence
            mechanism is the KahaDB store (identified by the kahaDB tag).
            For more information, see:

            http://activemq.apache.org/persistence.html
        -->
        <persistenceAdapter>
            <kahaDB directory="${activemq.data}/kahadb"/>
        </persistenceAdapter>


          <!--
            The systemUsage controls the maximum amount of space the broker will
            use before disabling caching and/or slowing down producers. For more information, see:
            http://activemq.apache.org/producer-flow-control.html
          -->
          <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage percentOfJvmHeap="70" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>

        <!--
            The transport connectors expose ActiveMQ over a given protocol to
            clients and other brokers. For more information, see:

            http://activemq.apache.org/configuring-transports.html
        -->
        <transportConnectors>
            <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        </transportConnectors>

        <!-- destroy the spring context on shutdown to stop jetty -->
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>

    </broker>

    <!--
        Enable web consoles, REST and Ajax APIs and demos
        The web consoles requires by default login, you can disable this in the jetty.xml file

        Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
    -->
    <import resource="jetty.xml"/>

</beans>
<!-- END SNIPPET: example -->

How should i fix this error?.

我应该如何解决这个错误?

采纳答案by Gandalf

My hostname which is localhost did not contain any underscores.The only underscore was in my computer name.My old name was computer_1but i changed it to computer1and now i am able to use localhost:8161activemq web console.

我的主机名 localhost 不包含任何下划线。唯一的下划线在我的计算机名称中。我的旧名称是computer_1但我将其更改为computer1现在我可以使用localhost:8161activemq Web 控制台。

To know how to change the computer name when on windows,do google it or refer to windows documentation.This error has nothing to do with hostname proper but rather the computer name.

要知道如何在 Windows 上更改计算机名称,请使用谷歌搜索或参考 Windows 文档。此错误与正确的主机名无关,而是与计算机名称有关。

回答by kos32

I had similar problem. The problem gone after reboot. Try to reboot PC and start activemq first. Probably it related that some ports were already taken.

我有类似的问题。重启后问题消失。尝试重新启动 PC 并首先启动 activemq。可能与一些端口已经被占用有关。

回答by Alexis Gamarra

Check your "activemq.log" in your "data" folder, in my case I obtain this error because I was using a "redeliveryPlugin" and it requires a schedulerSupport="true" in broker definition.

检查“data”文件夹中的“activemq.log”,在我的情况下,我收到此错误是因为我使用的是“redeliveryPlugin”,并且它在代理定义中需要 schedulerSupport="true" 。