无法启动指定代理配置文件的 ActiveMQ Classic

问题描述 投票:0回答:1

我正在关注 Manning 发布的 ActiveMQ in Action。我已在 Windows VM 中使用 Maven 成功构建了源代码“amq-in-action-example-src”。我使用与本书中的 ActiveMQ 相同的版本(即 5.4.1)。我按照第 4 章启动代理,如下所示:

C:\jliu2\apache-activemq-5.4.1>.\bin\activemq xbean:file:c:/jliu2/AMQinA-src/amq-in-action-example-src/src/main/resources/org/apache/activemq/book/ch4/brokerA.xml
Java Runtime: Oracle Corporation 1.8.0_311 C:\Program Files\Java\jdk1.8.0_311\jre
  Heap sizes: current=125952k  free=120624k  max=466432k
    JVM args: -Dcom.sun.management.jmxremote -Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Dactivemq.classpath=C:\jliu2\apache-activemq-5.4.1\bin\../conf;C:\jliu2\apache-activemq-5.4.1\bin\../conf; -Dactivemq.home=C:\jliu2\apache-activemq-5.4.1\bin\.. -Dactivemq.base=C:\jliu2\apache-activemq-5.4.1\bin\..
ACTIVEMQ_HOME: C:\jliu2\apache-activemq-5.4.1\bin\..
ACTIVEMQ_BASE: C:\jliu2\apache-activemq-5.4.1\bin\..
Loading message broker from: xbean:file:c:/jliu2/AMQinA-src/amq-in-action-example-src/src/main/resources/org/apache/activemq/book/ch4/brokerA.xml
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from URL [file:c:/jliu2/AMQinA-src/amq-in-action-example-src/src/main/resources/org/apache/activemq/book/ch4/brokerA.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 117; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'broker'.
java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from URL [file:c:/jliu2/AMQinA-src/amq-in-action-example-src/src/main/resources/org/apache/activemq/book/ch4/brokerA.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 117; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'broker'.
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:98)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:143)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.activemq.console.Main.runTaskClass(Main.java:251)
        at org.apache.activemq.console.Main.main(Main.java:107)
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from URL [file:c:/jliu2/AMQinA-src/amq-in-action-example-src/src/main/resources/org/apache/activemq/book/ch4/brokerA.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 117; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'broker'.

似乎无法识别XML文件中的

broker

我在这里粘贴

brokerA.xml
的一部分,与本书源代码中的内容相同:

  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="BrokerA" dataDirectory="${activemq.base}/data">
  
    <!-- The transport connectors ActiveMQ will listen to -->
    <transportConnectors>
       <transportConnector name="openwire" uri="tcp://localhost:61616" />
    </transportConnectors>
    
    <networkConnectors>
        <networkConnector uri="static:(tcp://localhost:61617)" />
    </networkConnectors>

  </broker>
  
</beans>

您能告诉我错误是什么以及如何修复它吗?

我完全按照书上的命令进行操作,如下:

.\bin\activemq xbean:src/main/resources/org/apache/activemq/book/ch4/brokerA.xml

(在 Windows 中,运行

activemq
而不是
activemq console

但似乎找不到该文件。于是我就跑了:

.\bin\activemq xbean:file:c:/jliu2/AMQinA-src/amq-in-action-example-src/src/main/resources/org/apache/activemq/book/ch4/brokerA.xml

这应该是正确的。

我也尝试过更改

brokeA.xml
中的某些内容,例如
xsi:schemaLocation, xmlns:amq
,但这没有用。

请注意

activemq
可以成功启动,并且我已经成功运行了第2章和第3章中的一些示例。我在第4章指定
brokerA.xml
中遇到了这样的问题。

xml activemq-classic
1个回答
0
投票

我在 GitHub 上找到了完整的

brokerA.xml
。我尝试运行 ActiveMQ Classic 5.4.1,但它太旧了(超过 13 岁),我没有所需的 Java 版本,所以我使用了 5.18.5。经纪人使用以下命令开始正常:

./activemq xbean:/path/to/brokerA.xml
不清楚你做错了什么,但我怀疑问题存在于你没有粘贴到问题中的

brokerA.xml

部分(例如架构位置)。

总的来说,我强烈建议您使用现代资源来学习ActiveMQ。就在

ActiveMQ in Action 发布几年后,ActiveMQ Artemis 被引入。这是 ActiveMQ 的下一代代理。它提供更好的性能、更高的可扩展性、更多协议支持、附加功能以及全面的文档示例

© www.soinside.com 2019 - 2024. All rights reserved.