用下载下来的activeMQ,只是修改了如下部分,在标准的 activemq.xml 中加入了一段:    <plugins>
        <simpleAuthenticationPlugin>
            <users>
                <authenticationUser username="system" password="${activemq.password}"
                    groups="users,admins"/>
                <authenticationUser username="user" password="${guest.password}"
                    groups="users"/>
                <authenticationUser username="guest" password="${guest.password}" groups="guests"/>
            </users>
        </simpleAuthenticationPlugin>
    </plugins> 
启动的时候就报这样的错误,请教是怎么回事啊?谢谢。ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreEx
ception: Line 59 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException:
 cvc-complex-type.2.4.a: Invalid content was found starting with element 'destinationPolicy'. One of '{"http://activemq.apache.org/sche
ma/core":producerSystemUsage, "http://activemq.apache.org/schema/core":proxyConnectors, "http://activemq.apache.org/schema/core":region
Broker, "http://activemq.apache.org/schema/core":services, "http://activemq.apache.org/schema/core":shutdownHooks, "http://activemq.apa
che.org/schema/core":sslContext, "http://activemq.apache.org/schema/core":systemUsage, "http://activemq.apache.org/schema/core":taskRun
nerFactory, "http://activemq.apache.org/schema/core":tempDataStore, "http://activemq.apache.org/schema/core":transportConnectorURIs, "h
ttp://activemq.apache.org/schema/core":transportConnectors, WC[##other:"http://activemq.apache.org/schema/core"]}' is expected.
java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException
: Line 59 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-co
mplex-type.2.4.a: Invalid content was found starting with element 'destinationPolicy'. One of '{"http://activemq.apache.org/schema/core
":producerSystemUsage, "http://activemq.apache.org/schema/core":proxyConnectors, "http://activemq.apache.org/schema/core":regionBroker,
 "http://activemq.apache.org/schema/core":services, "http://activemq.apache.org/schema/core":shutdownHooks, "http://activemq.apache.org
/schema/core":sslContext, "http://activemq.apache.org/schema/core":systemUsage, "http://activemq.apache.org/schema/core":taskRunnerFact
ory, "http://activemq.apache.org/schema/core":tempDataStore, "http://activemq.apache.org/schema/core":transportConnectorURIs, "http://a
ctivemq.apache.org/schema/core":transportConnectors, WC[##other:"http://activemq.apache.org/schema/core"]}' is expected.
        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: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:251)
        at org.apache.activemq.console.Main.main(Main.java:107)

解决方案 »

  1.   

    <transportConnectors>
                <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
    </transportConnectors>
    你transportConnectors这节点是不是在plugins前?我这里把transportConnectors节点放在broker的最后就可以了
    <broker>
        <plugins>
            <simpleAuthenticationPlugin>
                <users>
                    <authenticationUser username="system" password="${activemq.password}"
                        groups="users,admins"/>
                    <authenticationUser username="user" password="${guest.password}"
                        groups="users"/>
                    <authenticationUser username="guest" password="${guest.password}" groups="guests"/>
                </users>
            </simpleAuthenticationPlugin>
        </plugins>
     
            <transportConnectors>
                <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
            </transportConnectors>
    </broker>具体原因不明....
      

  2.   

    把你xml用浏览器打开,就知道错误了。
      

  3.   

    这是spring 3.0的问题,broker中元素的顺序不像以前那样无关紧要了~把destinationPolicy提到前面就可以了~
    <broker xmlns="http://activemq.apache.org/schema/core" 
            brokerName="FooBroker" 
            dataDirectory="/var/activemq/activemq-data"
            useJmx="true"> 
            <destinationPolicy>
                <policyMap>
                  <policyEntries>
                    <policyEntry topic=">">
                      <pendingSubscriberPolicy>
                        <vmCursor />
                      </pendingSubscriberPolicy>
                    </policyEntry>
                    <policyEntry queue=">">
                      <pendingQueuePolicy>
                        <vmQueueCursor />
                      </pendingQueuePolicy>
                    </policyEntry>
                  </policyEntries>
                </policyMap>
            </destinationPolicy>
     
          
            <managementContext>
                <managementContext createConnector="false"/>
            </managementContext>        <persistenceAdapter>
                <kahaDB directory="/var/activemq/activemq-data/kahadb"/>
            </persistenceAdapter>
     
            <systemUsage>
                <systemUsage>
                    <memoryUsage>
                        <memoryUsage limit="128 mb"/>
                    </memoryUsage>
                    <storeUsage>
                        <storeUsage limit="1 gb"/>
                    </storeUsage>
                    <tempUsage>
                        <tempUsage limit="100 mb"/>
                    </tempUsage>
                </systemUsage>
            </systemUsage>        <transportConnectors>
                <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
            </transportConnectors>    </broker>