前面的标题是:

如何内JBOSS 6使用Spring得到一个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>

我的applicationContext.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:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee 
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <jee:jndi-lookup id="jmsConnectionFactory" jndi-name="java:/JmsXA" />
    <jee:jndi-lookup id="jmsDestination" jndi-name="mytopic" expected-type="javax.jms.Topic" />
</beans>

这是使用JMX控制台org.jboss.naming.JNDIView输出:

  +- 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)

这在我的书装置,该主题被绑定到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参考的问题,但实际上,该大黄蜂队列不会在时间配置的应用程序启动时。

如果我一段时间后,部署应用程序,它会运行得很好,因为此时黄蜂队列的的配置。

有没有指定,直到剩下的就是启动的应用程序将无法启动,直到该队列,或者是一个JBoss部署的保持状态的配置选项的方式?

有帮助吗?

解决方案

我已成功使用JBoss中4.2“依赖”机制。有了它,你可以指定一些依赖于其他的东西(无论是使用XML描述或EJB3您可以使用标注)。这里是一个链接,让你开始

其他提示

如果您添加的java:/前缀(如你有JmsXA相同)?即。

<jee:jndi-lookup id="jmsDestination" jndi-name="java:/mytopic" expected-type="javax.jms.Topic" />

BTW,我没有看到你的JNDI转储下JmsXA名称定义的东西。你可能有一个问题了。

我没有使用HornetQ的,我只是你的问题的缘故阅读的教程一个HornetQ 一起设置弹簧。有一个节还有有关设置jndi.properties。这可能是确保HornetQ的注册它的东西到JBoss的JNDI上下文。

您确定您有一个文件,如他们认为,它的正确放置?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top