我在使用activeMQ作为JMS提供程序运行我的Spring JMS项目时遇到了麻烦。
线程"main"中的异常org.springframework.beans.factory.parsing.Bean定义解析异常:配置问题:无法定位Spring N amespaceHandler for XML模式名称空间[http://activemq.apache.org/schema/core]违规资源:类路径资源[spring.xml]
任何建议都将不胜感激。以下是代码:
Springxml
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">
<amq:connectionFactory id="mqConnectionFactory"
brokerURL="tcp://Toshiba:61616" />
<amq:topic id="topic1" physicalName="chattopic" />
<!-- a pooling based JMS provider -->
<bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://localhost:61616</value>
</property>
</bean>
</property>
</bean>
<!-- Spring JMS Template -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="mqConnectionFactory" />
</bean>
<!-- Our message listener implementation -->
<bean id="basicJMSChat" class="com.spring.jmsChat.BasicJMSChat">
<property name="chatJMSTemplate" ref="jmsTemplate" />
<property name="jmsTopic" ref="topic1" />
</bean>
<!-- message listener container -->
<bean id="poiMessageListenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="mqConnectionFactory" />
<property name="destination" ref="topic1" />
<property name="messageListener" ref="basicJMSChat" />
<property name="concurrentConsumers" value="1" />
</bean>
<context:annotation-config />
</beans>
java类
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
public class BasicJMSChat implements MessageListener{
public static void main(String[] args) throws JMSException, IOException {
if (args.length != 1) {
System.out.println("User ID id required!");
} else {
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
BasicJMSChat basicJMSChat = (BasicJMSChat) context.getBean("basicJMSChat");
TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory) basicJMSChat.chatJmsTemplate.getConnectionFactory();
TopicConnection topicConnection =
topicConnectionFactory.createTopicConnection();
basicJMSChat.publish(topicConnection, basicJMSChat.chatTopic, userId);
basicJMSChat.subscriber(topicConnection, basicJMSChat.chatTopic, basicJMSChat);
}
}
}
错误:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring N
amespaceHandler for XML schema namespace [http://activemq.apache.org/schema/core]
Offending resource: class path resource [spring.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:301)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1408)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1401)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:17
2)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.ja
va:142)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java
:94)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:12
9)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:613)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:514)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.spring.jmsChat.BasicJMSChat.main(BasicJMSChat.java:104)
需要验证的一些事情:
如果使用maven:执行干净的安装
如果你用爆炸的libs创建了一场战争,这可能是个问题,因为它会覆盖amq的配置、服务和xsd文件
你能发pom吗。xml
或者像这样改变你的定义:
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd">
<bean id="mqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://Toshiba:61616" />
</bean>
<bean id="topic1" class="org.apache.activemq.command.ActiveMQTopic">
<property name="physicalName" value="chattopic" />
</bean>
更新
库文件夹结构
我没有用maven。
问题内容: 我正在使用Spring Batch为我们的数据仓库构建累积快照,并且遇到了无法确定的配置障碍。 我已经使用Spring Template Project使用STS(SpringSource Tool Suite 2.8.1)创建了一个简单Spring Batch 项目。这些是我创建的两个xml配置文件: launch-context.xml and module-context.xml
问题内容: 任何想法可能是什么原因? 无法找到用于XML模式名称空间的Spring NamespaceHandler [http://www.springframework.org/schema/security] 这是我的applicationContext.xml: 在我的pom.xml中,我有: 问题答案: 我需要添加一个附加的Maven依赖项:
问题内容: 我的设置非常简单:我有一个Web前端,后端是弹簧接线的。 我正在使用AOP在rpc服务上增加一层安全性。 一切都很好,除了Web应用程序在启动时中止的事实: 这是我的xml配置文件中的代码段: 我在互联网上读到,这可能是我上课负担问题的核心。令人怀疑的是,因为这是我的WEB-INF / lib目录: 问题答案: 您是否尝试过将所有罐子直接放在目录中而不是其子目录中? 不,只是 其余的罐
问题内容: 我正在尝试将JUnit和Spring结合在一个Web项目中。由于这个问题,我已成功将spring config文件加载到TestClass中: 但是当测试运行时,出现以下错误: 由以下原因引起:org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML模式命名空间的Sprin
我有一个XML模式(称为DataQualityCalculationTasks.xsd),它没有声明目标命名空间http://www.w3.org/tr/xmlSchema-0/#UndeclaredTns。我在WSDL文件中导入了这个XML模式,如下所示: 但是,我在Eclipse中得到以下错误: 谢谢!