JNDI不适用于HornetQ和tomcat [英] JNDI does not work with HornetQ and tomcat

查看:127
本文介绍了JNDI不适用于HornetQ和tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Tomcat上使用hornetq运行JMS应用程序!我尝试了以下本文 .我将jndi.properties放在客户端类路径中; jndi.properties:

I'm trying running JMS application using hornetq on tomcat! I tried following this article. I put jndi.properties in my client class path; jndi.properties:

java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory 
java.naming.factory.url.pkgs=org.apache.naming

我将这些依赖项添加到pom.xml:

I added these dependencies to pom.xml:

<dependency> 
    <groupId>tomcat</groupId> 
    <artifactId>naming-factory</artifactId> 
    <version>5.5.23</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
     <groupId>tomcat</groupId> 
     <artifactId>naming-resources</artifactId> 
     <version>5.5.23</version> 
     <scope>test</scope> 
 </dependency>

我的JMS春季豆:

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">org.apache.naming.java.javaURLContextFactory</prop>
                <prop key="java.naming.factory.url.pkgs">org.apache.naming</prop>
            </props>
        </property>
    </bean>

<!-- Connection Factory -->
<bean id="hornetqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="/ConnectionFactory" />
</bean>

<!-- Destinations -->
<bean id="annotationDeleteCommandDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="/queue/command/annotation/deleteQueue" />
</bean>

我正在使用HornetQ默认服务器(独立,非群集)

I'm using HornetQ default server (standalone, non-clustered)

hornetq-jms.xml:

hornetq-jms.xml:

<queue name="annotationDeleteCommandQueue">
    <entry name="/queue/command/annotation/deleteQueue"/>
</queue>

<connection-factory name="NettyConnectionFactory">
      <xa>false</xa>
      <connectors>
         <connector-ref connector-name="netty"/>
      </connectors>
      <entries>
         <entry name="/ConnectionFactory"/>
      </entries>
   </connection-factory>

但是当我启动tomcat时,出现此错误:

But when i starting tomcat i get this error:

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hornetqConnectionFactory' defined in ServletContext resource [/WEB-INF/classes/config/spring/applicationContext-jms.xml]: 
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name ConnectionFactory is not bound in this Context .........

怎么了? 我应该在tomcat类路径中放置任何jar文件吗? (哪个罐子?) 我应该在tomcat配置中放入队列和连接工厂定义吗? (如何?) 我可以在tomcat中禁用JNDI并改用hornetq独立JNDI吗?

What is wrong? Should i put any jar files in the tomcat classpath? (which jars?) Should i put queues and connection factories definitions in the tomcat configs? (how?) Can i disable JNDI in tomcat and use hornetq standalone JNDI instead?

推荐答案

我通过修改jndiTemplate(使用jboss命名)并将jnp-client.jar添加到客户端类路径来解决了这个问题:

I solved this problem by modification of jndiTemplate (using jboss naming) and adding jnp-client.jar to client classpath:

<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.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
            <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
        </props>
    </property>
</bean>

这篇关于JNDI不适用于HornetQ和tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆