Invalid ActiveMQ Schema Name Space

来源:互联网 发布:thug life 视频软件 编辑:程序博客网 时间:2024/05/16 04:30

From: http://www.bigsoft.co.uk/blog/index.php/2009/02/01/invalid-activemq-schema-name-space

Newer versions of ActiveMQ have support for XML name space schema declarations to allow easier configuration of container beans. Adding the following XMLNS declaration to thebeans container will allow you to use ActiveMQ’s amq name space.

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amq="http://activemq.apache.org/schema/core"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd"><!--  lets create an embedded ActiveMQ Broker --><amq:broker useJmx="true" persistent="false"><amq:managementContext><amq:managementContext connectorPort="61617"/></amq:managementContext><amq:transportConnectors><amq:transportConnector uri="tcp://192.168.16.15:61619" /></amq:transportConnectors></amq:broker></beans>

When the application is deployed (in Tomcat) it will work as expected, however if you try to run it under Eclipse the container fails to start with the message:

org.xml.sax.SAXParseException: schema_reference.4:Failed to read schema document 'http://activemq.apache.org/schema/core/activemq-core.xsd',because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c:The matching wildcard is strict,but no declaration can be found for element 'amq:broker'. </xsd>

The amq:broker maybe replaced with amq:connectionFactory depending on which name elements you have actually used.

In order for Eclipse to understand the amq name space you must add xbean support for ActiveMQ. This is achieved by addingxbean-spring-3.4.jar to your dynamic web project.

According to the ActiveMQ website the XSD declaration will be automatically fished out of the jar and used to help Eclipse give you features like command completion for the XML schema. In fact what happens, is that Eclipse lights up like a Christmas tree moaning that it can’t find the schema declaration. Below is a set of instructions to tell Eclipse how to associate theactivemq-core.xsd url with the activemq-core.xsd found in the jar file which is shipped as part of ActiveMQ.

  1. Select Windows->Preferences from the Eclipse menu bar.
  2. Select XML->XML Catalog from the left hand configuration tree.
  3. Highlight User Specified Entries and select Add.
  4. The Add XML Catalog Entry windows appears.
  5. In the Location enter the path to the activemq-all jar, then add !/activemq.xsd to the end of the jar name. e.g.jar:file:C:/Java/libs/activemq/apache-activemq-5.2.0/activemq-all-5.2.0.jar!/activemq.xsd
  6. Under KeyType enter Namespace Name
  7. and under Key enter http://activemq.apache.org/schema/core
  8. then click Ok.
  9. Now we need to do the same for the other name space file, so hit Add again.
  10. In the Location enter the path to the activemq-all jar, then add !/activemq.xsd to the end of the jar name. e.g. jar:file:C:/Java/libs/activemq/apache-activemq-5.2.0/activemq-all-5.2.0.jar!/activemq.xsd
  11. Under KeyType enter Schema Location
  12. and under Key enter http://activemq.apache.org/schema/core/activemq-core.xsd
  13. Click Ok, Ok.

The Spring IDE should do its thing and the red error markers will disappear.