Java 未找到架构为jms的组件
我正在从事一个项目,我们决定使用jms和hornetq作为提供者添加一些交互。Java 未找到架构为jms的组件,java,xml,jms,apache-camel,hornetq,Java,Xml,Jms,Apache Camel,Hornetq,我正在从事一个项目,我们决定使用jms和hornetq作为提供者添加一些交互。 我对骆驼很陌生,所以我遇到了一个问题,如果你认为是琐碎的话 目标是初始化连接工厂并添加jms组件。但是,据我所知,不能直接在route configurator中完成。因此,我创建了camel-config.xml并将其放在resources/目录中。 我按以下方式填写: <beans xmlns="http://www.springframework.org/schema/beans" xmln
我对骆驼很陌生,所以我遇到了一个问题,如果你认为是琐碎的话
目标是初始化连接工厂并添加jms组件。但是,据我所知,不能直接在route configurator中完成。因此,我创建了camel-config.xml并将其放在resources/目录中。
我按以下方式填写:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
</props>
</property>
</bean>
<bean id="jmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>ConnectionFactory</value>
</property>
</bean>
<bean name="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsQueueConnectionFactory"/>
</bean>
</beans>
org.jnp.interfaces.NamingContextFactory
jnp://localhost:1099
接口:org.jboss.naming
连接工厂
该项目不使用Spring,因此它是我发现的唯一一个不使用Spring的xml示例。
在路由配置器中,我使用routeBuilder.from(“jms:queue:top”).to(“…”)代码>
但是,当我启动项目时,它会抛出FailedToCreateEndpointException并声明
“未找到架构为jms的组件”
我想xml文件根本没有被使用,但我就是不明白如何指向它。
期待听到任何建议 XML是一种Spring配置,必须以某种方式进行引导。您可以看看找到的Tomcat ActiveMQ示例,它展示了如何在servlet环境中实现这一点。请特别关注web.xml
:
<!-- location of spring XML files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:broker.xml,
classpath:camel-config.xml
</param-value>
</context-param>
<!-- the listener that kick-starts Spring, which loads the XML files and start our application -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
这实际上是在使用Spring,正如Peter所说,它需要引导或替换。但是,在进行任何其他操作之前,请先验证是否确实添加了驼峰jms依赖项。这是当错过类路径上的组件时发生的错误类型。
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
ModelCamelContext context = new DefaultCamelContext();
context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));