2 Replies Latest reply on May 10, 2012 1:03 PM by yweintraub

    Remote JNDI lookup with JBoss 7.1.1 & context java:jboss/exported failed

    sebbay

      Hey,

       

      I read this article on https://docs.jboss.org/author/display/AS71/JNDI+Reference and recognized, that it should be possible to access remote JNDI entries, which are provided in java:jboss/exported context.

       

      To test this issue, I added a webapp with the following web.xml to the JBoss-Server 7.1.1:

       

      <web-app version="3.0"

      xmlns="http://java.sun.com/xml/ns/javaee"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

          <env-entry>

              <env-entry-name>java:global/mystring</env-entry-name>

              <env-entry-type>java.lang.String</env-entry-type>

              <env-entry-value>Hello World</env-entry-value>

          </env-entry>

          <env-entry>

              <env-entry-name>java:jboss/exported/hello</env-entry-name>

              <env-entry-type>java.lang.String</env-entry-type>

              <env-entry-value>Hello Module</env-entry-value>

          </env-entry>

      </web-app>

       

      However, when dumping the JNDI namespace, the entry for ‘hello’ is missing and I cannot access it from remote.

       

      /subsystem=naming:jndi-view

      {

          "outcome" => "success",

          "result" => {

              "java: contexts" => {

                  "java:jboss" => {

                      "TransactionManager" => {

                          "class-name" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate",

                          "value" => "com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@68bfa5"

                      },

      "TransactionSynchronizationRegistry" => {

                          "class-name" => "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple",

                          "value" => "com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple@1c2bc32"

                      },

                      "UserTransaction" => {

                          "class-name" => "org.jboss.tm.usertx.client.ServerVMClientUserTransaction",

                          "value" => "org.jboss.tm.usertx.client.ServerVMClientUserTransaction@f9da76"

                      },

                      "jaas" => {

                          "class-name" => "$Proxy27",

                          "children" => {

      "jboss-ejb-policy" => {

      "class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",

                                  "value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@125315b"

                              },

                              "B3RealmJaas" => {

      "class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",

                                  "value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@cb6484"

                              },

                              "other" => {

      "class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",

                                  "value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@13449ce"

                              },

      "jboss-web-policy" => {

                                  "class-name" => "org.jboss.as.security.plugins.SecurityDomainContext",

                                  "value" => "org.jboss.security.authentication.JBossCachedAuthenticationManager@1d9a74a"

                              }

                          }

                      },

                      "mail" => {

                          "class-name" => "javax.naming.Context",

                          "children" => {"Default" => {

                              "class-name" => "javax.mail.Session",

                              "value" => "javax.mail.Session@1e1cc3e"

                          }}

                      },

                      "exported" => {

                          "class-name" => "javax.naming.Context",

                          "value" => "org.jboss.as.naming.WritableServiceBasedNamingStore@128008a"

                      }

                  },

                  "java:global" => {"mystring" => {

                      "class-name" => "java.lang.String",

                      "value" => "Hello World"

                  }}

              },

              "applications" => {"samplelog.war" => {

                  "java:app" => {

                      "AppName" => {

                          "class-name" => "java.lang.String",

                          "value" => "samplelog"

                      },

                      "env" => {

                          "class-name" => "org.jboss.as.naming.NamingContext",

                          "children" => undefined

      }

                  },

      "modules" => undefined

              }}

          }

      }

       

      I am invoking the JNDI from remote with the following code:

       

      final Properties jndiProperties = new Properties();

      jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");

      jndiProperties.put(Context.PROVIDER_URL, "remote://10.2.2.34:10006");

      jndiProperties.put(Context.SECURITY_PRINCIPAL, "guest");

      jndiProperties.put(Context.SECURITY_CREDENTIALS, "guest");

      jndiProperties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

      jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

      jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");

      jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");

       

      context = new InitialContext(jndiProperties);

      EJBObject ejbObject = null;

                 

      String s = (String)context.lookup("java:jboss/exported/hello");

      System.out.println("s : " + s);

       

      … which results in this exception:

       

      javax.naming.NameNotFoundException: java:jboss/exported/hello

        at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:117)

        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)

        at javax.naming.InitialContext.lookup(InitialContext.java:392)

        at Test.doLookup(Test.java:72)

        at Test.main(Test.java:21)

       

      Some ideas?

       

      Best regards,

      sebbay