如何获取新的 JNDI 名称(尤其是 ConnectionFactory)

发布于 2024-12-06 03:12:48 字数 491 浏览 0 评论 0原文

我升级到 JBoss 7.0.1,我们使用以下 JNDI 查找来获取与 HornetQ 消息队列的连接。

InitialContext jndiContext = new InitialContext();
QueueConnectionFactory qf = (QueueConnectionFactory) jndiContext.lookup( "ConnectionFactory" );

当与 JBoss 7 一起使用时,这会导致 NameNotFoundException 。我还尝试了以下方法:

  • java:jms/ConnectionFactory
  • java:env/ConnectionFactory

.. 以及其他一些方法。但我认为猜测不会让我走得太远。如何获取未记录在控制台中的新 JNDI 名称(例如我的 EJB bean)?

亲切的问候, 塞巴斯蒂安

I upgraded to JBoss 7.0.1 and we are using the following JNDI lookup to get a connection to a HornetQ message queue.

InitialContext jndiContext = new InitialContext();
QueueConnectionFactory qf = (QueueConnectionFactory) jndiContext.lookup( "ConnectionFactory" );

This results in a NameNotFoundException when used with JBoss 7. I have also tried the following:

  • java:jms/ConnectionFactory
  • java:env/ConnectionFactory

.. and some others. But I think guessing won't get me far. How do I get the new JNDI names that are not logged in the console (like my EJB beans)?

Kind regards,
Sebastian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甩你一脸翔 2024-12-13 03:12:48

尝试

java:jboss/ConnectionFactory

没有测试它,但会尝试一下,因为

不合格的相对名称,例如“DefaultDS”或“jdbc/DefaultDS”
应该相对于“java:comp/env”、“java:module/env”进行限定,或者
“java:jboss/env”,取决于上下文。

更正和编辑:查看了我的安装,正确的是:

java:/ConnectionFactory

也在domain.xml 中定义。

Try

java:jboss/ConnectionFactory

Did not test it, but would give that a try, since https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 says:

Unqualified relative names like "DefaultDS" or "jdbc/DefaultDS"
should be qualified relative to "java:comp/env", "java:module/env", or
"java:jboss/env", depending on the context.

Correction and edit: Had a look at my installation and correct is:

java:/ConnectionFactory

as it is defined in domain.xml also.

骄兵必败 2024-12-13 03:12:48

解决了:

整个 HornetQ 部分在 JBoss 7 中默认被停用。必须将相应部分从 standalone-preview.xml 复制到 standalone.xml 并将所有内容从META-INF/hornetq-jms.xml 到 JBoss 配置。

现在我已经像这样配置了 ConnectionFactory:

        <jms-connection-factories>
            <connection-factory name="InVmConnectionFactory">
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="ConnectionFactory"/>
                </entries>
            </connection-factory>
        </jms-connection-factories>

我可以通过执行此 JNDI 查找来使用它:

QueueConnectionFactory qf = (QueueConnectionFactory) jndiContext.lookup( "java:/ConnectionFactory" );

这是由

Solved it:

The whole HornetQ part was deactivated by default in JBoss 7. Had to copy the corresponding part from the standalone-preview.xml to standalone.xml and move everything from META-INF/hornetq-jms.xml to the JBoss config.

Now I have the ConnectionFactory configured like this:

        <jms-connection-factories>
            <connection-factory name="InVmConnectionFactory">
                <connectors>
                    <connector-ref connector-name="in-vm"/>
                </connectors>
                <entries>
                    <entry name="ConnectionFactory"/>
                </entries>
            </connection-factory>
        </jms-connection-factories>

and I can use it by doing this JNDI lookup:

QueueConnectionFactory qf = (QueueConnectionFactory) jndiContext.lookup( "java:/ConnectionFactory" );

This is caused by a bug in the JMS configuration of JBoss 7. Seems to be fixed in 7.0.1, used that version, didn't notice any fix - however, the above configuration works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文