Search code examples
jndijboss7.x

How to get the new JNDI names (esp. ConnectionFactory)


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


Solution

  • 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.