Spring 当我的webapp在JBOSS 6.0中启动时,如何确保hornet队列在那里?

Spring 当我的webapp在JBOSS 6.0中启动时,如何确保hornet队列在那里?,spring,jboss,jndi,hornetq,jboss6.x,Spring,Jboss,Jndi,Hornetq,Jboss6.x,以前的标题是: 如何使用Spring获取JBOSS 6中队列的JNDI引用? 我像这样配置了一个JMS队列,它位于文件mytopic-hornetq-JMS.xml中: <?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:

以前的标题是:

如何使用Spring获取JBOSS 6中队列的JNDI引用?

我像这样配置了一个JMS队列,它位于文件mytopic-hornetq-JMS.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="urn:hornetq"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
    <topic name="mytopic">
        <entry name="mytopic"/>
    </topic>
</configuration>
在我的书中,这意味着主题绑定到JNDI名称“mytopic”

然而,春天会扔吗

18:45:29,636 ERROR [ContextLoader] Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsDestination': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: mytopic not bound
...
Caused by: javax.naming.NameNotFoundException: mytopic not bound
  at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]
  at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]
  at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]
  at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]
更新

看起来,查找JNDI引用实际上不是一个问题,而是在应用程序启动时没有配置hornet队列

如果我稍后部署应用程序,它将正常运行,因为此时已配置hornet队列


有没有一种方法可以指定应用程序在队列完成之前不会启动,或者jboss的配置选项是在其余的队列启动之前保持部署?

如果添加
java:///code>前缀(与JmsXA相同),会怎么样?i、 e



顺便说一句,我在JNDI转储中没有看到在
JmsXA
name下定义的任何内容。你可能对此也有问题。

我没有使用HornetQ,我只是为了你的问题阅读了。那里有一个关于设置
jndi.properties
的部分。这可能是为了确保HornetQ将其内容注册到JBoss JNDI上下文中


你确定你有一个像他们建议的那样的文件并且它的位置正确吗?

我已经成功地使用了JBoss4.2中的“依赖”机制。有了它,您可以指定某些内容依赖于其他内容(使用xml描述符,或者对于ejb3,您可以使用注释)。这里有一个链接可以帮助您

我已经尝试了不同的组合。JNDI转储只是全局命名空间的转储。JmsXA实际上是在java前缀下注册的,因此它不包括在全局名称空间中,并且查找工作正常。
  +- UserTransactionSessionFactory (proxy: $Proxy103 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
  +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
  +- SecureDeploymentManager (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> DeploymentManager] (class: javax.naming.LinkRef)
  +- SecureManagementView (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> ManagementView] (class: javax.naming.LinkRef)
  +- mytopic (class: org.hornetq.jms.client.HornetQTopic)
  +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
  +- XAConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- ProfileService (class: org.jboss.aop.generatedproxies.AOPProxy$2)
  +- SecureProfileService (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> ProfileService] (class: javax.naming.LinkRef)
  +- queue (class: org.jnp.interfaces.NamingContext)
  |   +- DLQ (class: org.hornetq.jms.client.HornetQQueue)
  |   +- ExpiryQueue (class: org.hornetq.jms.client.HornetQQueue)
  +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  +- ConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- jmx (class: org.jnp.interfaces.NamingContext)
  |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (class: javax.management.MBeanServerConnection)
  |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (class: javax.management.MBeanServerConnection)
  +- BeanValidatorFactories (class: org.jnp.interfaces.NamingContext)
  +- TomcatAuthenticators (class: java.util.Properties)
  +- XAThroughputConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- ManagementView (class: org.jboss.aop.generatedproxies.AOPProxy$3)
  +- ThroughputConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
18:45:29,636 ERROR [ContextLoader] Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsDestination': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: mytopic not bound
...
Caused by: javax.naming.NameNotFoundException: mytopic not bound
  at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]
  at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]
  at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]
  at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]
<jee:jndi-lookup id="jmsDestination" jndi-name="java:/mytopic" expected-type="javax.jms.Topic" />