2013-04-05 47 views
0

在本地,我的应用程序可以很好地连接到内置的Netty ConnectionFactory,并且在启动或发送主题消息时没有问题。我的本地盒子是独立的JBoss 5.1和独立的HornetQ。无法使用Spring 3连接到JBoss 5中的HornetQ连接工厂

然而,部署到我们的开发服务器时(运行群集的JBoss 5.1和群集HornetQ的),我无法连接,得到以下堆栈跟踪:

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/eShowroom]] (main) Exception sending context initialized event to listener instance of cla>\ss org.springframework.web.context.ContextLoaderListener 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'topicConnectionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ConnectionFactory not bound 

我试图使用默认,内置netty连接器,除了我自己的JMS主题外没有额外的配置。我相对不知道DEV服务器设置,因为它超出了我的控制范围,并且相当于黑箱。

的applicationContext.xml(在$JBOSS_HOME/server/default/deploy/application.war/WEB-INF):

<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://${jboss.bind.address:localhost}:1099</prop> 
       <prop key="java.naming.factory.url.pkgs">org.jboss.naming</prop> 
      </props> 
     </property> 
    </bean> 

    <bean id="topicConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> 
     <property name="jndiTemplate" ref="jndiTemplate"></property> 
     <property name="jndiName" value="/ConnectionFactory"></property> 
    </bean> 

    <bean id="cacheTopic" class="org.springframework.jndi.JndiObjectFactoryBean"> 
     <property name="jndiTemplate" ref="jndiTemplate"></property> 
     <property name="jndiName" value="/topic/myCacheTopic"></property> 
    </bean> 

    <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver"> 
     <property name="jndiTemplate" ref="jndiTemplate"/> 
     <property name="cache" value="true"/> 
    </bean> 

    <bean id="messageSendTemplate" class="org.springframework.jms.core.JmsTemplate"> 
     <property name="connectionFactory" ref="topicConnectionFactory"/> 
     <property name="destinationResolver" ref="jmsDestinationResolver"/> 
     <property name="pubSubDomain" value="true"/> 
    </bean> 

将hornetq-jms.xml文件(在$JBOSS_HOME/server/default/deploy/hornetq.sar

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

    <connection-factory name="NettyThroughputConnectionFactory"> 
     <xa>true</xa> 
     <connectors> 
     <connector-ref connector-name="netty-throughput"/> 
     </connectors> 
     <entries> 
      <entry name="/ThroughputConnectionFactory"/> 
      <entry name="/XAThroughputConnectionFactory"/> 
     </entries> 
    </connection-factory> 

    <connection-factory name="InVMConnectionFactory"> 
     <xa>true</xa> 
     <connectors> 
     <connector-ref connector-name="in-vm"/> 
     </connectors> 
     <entries> 
     <entry name="java:/ConnectionFactory"/> 
     <entry name="java:/XAConnectionFactory"/> 
     </entries> 
    </connection-factory> 

本地和DEV之间的唯一区别,我可以很容易地spot位于hornetq-configuration.xml中。

DEV hornetq-configuration.xml文件(相同的路径将hornetq-jms.xml文件)

<broadcast-groups> 
     <broadcast-group name="bg-group1"> 
     <group-address>${hornetq.broadcast.bg-group1.address:231.7.7.7}</group-address> 
     <group-port>${hornetq.broadcast.bg-group1.port:9876}</group-port> 
     <broadcast-period>5000</broadcast-period> 
     <connector-ref>netty</connector-ref> 
     </broadcast-group> 
    </broadcast-groups> 

    <discovery-groups> 
     <discovery-group name="dg-group1"> 
     <group-address>${hornetq.discovery.dg-group1.address:231.7.7.7}</group-address> 
     <group-port>${hornetq.discovery.dg-group1.port:9876}</group-port> 
     <refresh-timeout>10000</refresh-timeout> 
     </discovery-group> 
    </discovery-groups> 

    <cluster-connections> 
     <cluster-connection name="my-cluster"> 
     <address>jms</address> 
     <connector-ref>netty</connector-ref> 
      <discovery-group-ref discovery-group-name="dg-group1"/> 
     </cluster-connection> 
    </cluster-connections> 
+0

你试过 <属性名=“jndiName”值=“连接工厂”> 也就是说,没有前导“/”之名。 – 2013-06-04 16:57:42

回答

0

所以,事实证明,无论出于何种原因,这是在集群环境中的计时问题。需要连接工厂的bean只是被迫等到其他所有东西都启动并运行之后才启动。

相关问题