8 Replies Latest reply on Jul 13, 2011 11:17 AM by Simon Martinelli

    JNDI Names

    Simon Martinelli Novice

      I'm trying to port a application from JBoss 6 to 7.

      Unfortunatly there were some changes with the JNDI names and I'm not able to deploy my application.

       

      What are the correct JNDI names to use in the application for the message queues and connectionfactory?

       

      Definitions in standalone.xml

       

                <connection-factory name="InVmConnectionFactory">

                       <connectors>

                          <connector-ref connector-name="in-vm"/>

                       </connectors>

                       <entries>

                          <entry name="java:/ConnectionFactory"/>

                       </entries>

                    </connection-factory>

       

          <jms-destinations>

                    <jms-queue name="testQueue">

                       <entry name="queue/test"/>

                    </jms-queue>

                    <jms-topic name="testTopic">

                       <entry name="topic/test"/>

                    </jms-topic>

                    <jms-queue name="bestellqueue">

                       <entry name="queue/bestellqueue"/>

                    </jms-queue>

                 </jms-destinations>

       

      How can I access these from my application?

       

      With JBoss 6 I used:

       

          @Resource(mappedName = "ConnectionFactory")
          private ConnectionFactory connectionFactory;

          @Resource(mappedName = "queue/bestellqueue")
          private Queue queue;

       

       

      Thanks for you help.

       

      Simon

        • 1. Re: JNDI Names
          Prasad Deshpande Expert

          the one that worked for me is to use "java:/" before queue or topic. So in your case it will be :

           

          for connectionfactory use: java:/ConnectionFactory

           

          for topic & queue

           

          "java:/queue/test", "java:/bestellqueue" & "java:/topic/test".

           

          Use following:

              @Resource(mappedName = "java:/ConnectionFactory")
              private ConnectionFactory connectionFactory;

              @Resource(mappedName = "java:/queue/bestellqueue")
              private Queue queue;

          • 2. Re: JNDI Names
            Simon Martinelli Novice

            Thanks for your answer.

             

            Unfortunatly this doesn't work for me:

            missing [ jboss.naming.context.java.ConnectionFactory ]

            • 3. Re: JNDI Names
              Prasad Deshpande Expert

              Can you post your <jms-connection-factories> node? Also, are you using hornetq-ra as a pooled connectionfactory? for me it is

              <pooled-connection-factory name="hornetq-ra">

              <connectors>

              <connector-ref connector-name="in-vm"/>

              </connectors>

              <entries>

              <entry name="java:/JmsXA"/>

              </entries>

              </pooled-connection-factory>

              so I use "java:/JmsXA" as mappedName in @Resource annotation.

              • 4. Re: JNDI Names
                Simon Martinelli Novice

                <jms-connection-factories>
                              <connection-factory name="InVmConnectionFactory">
                                 <connectors>
                                    <connector-ref connector-name="in-vm"/>
                                 </connectors>
                                 <entries>
                                    <entry name="java:/ConnectionFactory"/>
                                 </entries>
                              </connection-factory>
                              <connection-factory name="RemoteConnectionFactory">
                                 <connectors>
                                    <connector-ref connector-name="netty"/>
                                 </connectors>
                                 <entries>
                                    <entry name="RemoteConnectionFactory"/>
                                 </entries>
                              </connection-factory>
                              <pooled-connection-factory name="hornetq-ra">
                                 <transaction mode="xa"/>
                                 <connectors>
                                    <connector-ref connector-name="in-vm"/>
                                 </connectors>
                                 <entries>
                                    <entry name="java:/JmsXA"/>
                                 </entries>
                              </pooled-connection-factory>
                           </jms-connection-factories>

                • 5. Re: JNDI Names
                  Prasad Deshpande Expert

                      @Resource(mappedName = "java:/JmsXA")
                      private ConnectionFactory connectionFactory;

                      @Resource(mappedName = "java:/queue/bestellqueue")
                      private Queue queue;

                  should work for you.

                  1 of 1 people found this helpful
                  • 6. Re: JNDI Names
                    Simon Martinelli Novice

                    Thanks Prasad, this helped. With java:/JmsXA theres no more error message but with ConnectionFactory it does not work.

                     

                    But now I run in another problem.

                     

                    I have defined a SecurityRealm:

                     

                    <security-realm name="ActiveDirectory">
                           <authentication>
                            <properties path="shop-users.properties" relative-to="jboss.server.config.dir" />
                           </authentication>
                          </security-realm>

                     

                    And have a mapping in jboss-web.xml:

                     

                     

                     

                    <jboss-web>

                     

                     

                    <security-domain>java:/jaas/ActiveDirectory</security-domain>

                    </jboss-web>

                     

                    But it does not find it:

                     

                    missing [ jboss.security.security-domain.ActiveDirectory ]

                     

                    Any ideas on that?

                    • 7. Re: JNDI Names
                      jaikiran pai Master

                      Simon Martinelli wrote:

                       

                      Thanks Prasad, this helped. With java:/JmsXA theres no more error message but with ConnectionFactory it does not work.

                       

                      But now I run in another problem.

                       

                      I have defined a SecurityRealm:

                       

                      <security-realm name="ActiveDirectory">
                             <authentication>
                              <properties path="shop-users.properties" relative-to="jboss.server.config.dir" />
                             </authentication>
                            </security-realm>

                       

                      security-realm? That's used for the management interfaces. You should be using a security-domain in the security subsystem. Check the standalone.xml/domain.xml which has an example.

                       

                       

                      Simon Martinelli wrote:

                       

                      And have a mapping in jboss-web.xml:

                       

                      <jboss-web>

                       

                       

                      <security-domain>java:/jaas/ActiveDirectory</security-domain>

                      </jboss-web>

                       

                       

                       

                       

                      Once you have setup the security-domain, then within the jboss-web.xml, just use the security domain name and not the jndi name:

                       

                      <jboss-web>
                        <security-domain>ActiveDirectory</security-domain>
                      </jboss-web>
                      
                      • 8. Re: JNDI Names
                        Simon Martinelli Novice

                        Oh I see. But there is no useful example.

                         

                        What's the replacement for login-config.xml <= AS6? I like to use LDAP for authentication.

                        That's how I did it in AS 6

                         

                        <application-policy name="ActiveDirectory">
                            <authentication>
                              <login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required" >
                                <!-- Some AD configurations may require searching against the Global Catalog on port 3268 instead of the usual port 389.
                                     This is most likely when the AD forest includes multiple domains. -->
                                <module-option name="java.naming.provider.url">ldap://xy.ch:3168</module-option>
                           <module-option name="java.naming.security.authentication">simple</module-option>
                                <module-option name="bindDN">ad\ab</module-option>
                                <module-option name="bindCredential">xy</module-option>
                                <module-option name="baseCtxDN">dc=ad,dc=bls,dc=ch</module-option>
                                <module-option name="baseFilter">(sAMAccountName={0})</module-option>
                                <module-option name="rolesCtxDN">dc=ad,dc=bls,dc=ch</module-option>
                                <module-option name="roleFilter">(member={1})</module-option>
                                <module-option name="roleAttributeIsDN">true</module-option>
                                <module-option name="roleNameAttributeID">name</module-option>
                              </login-module>
                           <login-module code="org.jboss.security.auth.spi.RoleMappingLoginModule" flag="optional">
                                <module-option name="rolesProperties">props/rolesMapping-roles.properties</module-option>
                              </login-module>  
                            </authentication>
                          </application-policy>