6 Replies Latest reply on Mar 21, 2018 10:13 AM by Søren Hilmer

    WildFly 11 remote JNDI lookup

    Søren Hilmer Newbie

      Hi,

       

      I'm trying to remotely lookup a value registered in JNDI naming on WildFly 11 like this:

              <subsystem xmlns="urn:jboss:domain:naming:2.0">

                <bindings>

                  <simple name="java:global/myname" value="TTTT" type="String" />

                </bindings>

                <remote-naming/>

              </subsystem>

       

      My "lookup" looks like:

       

      public class ExternalClient {

       

      static Context getInitialContext() throws NamingException

       

        {

       

         Properties properties = new Properties();

       

        properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");

        properties.put(Context.PROVIDER_URL, "remote+http://localhost:8080");

        properties.put(Context.SECURITY_PRINCIPAL, "xxx");

        properties.put(Context.SECURITY_CREDENTIALS, "yyyy");

         return new InitialContext(properties);

      }

       

       

      public static void main(String[] args) throws NamingException, RemoteException {

       

          System.out.println("Starting ExternalClient Test...");

          Context jndiContext = getInitialContext();

          String  name =   (String)jndiContext.lookup("java:global/myname");

          System.out.println("NAME: "+name);

      }

      }

       

       

      When I run this I get:

      Starting ExternalClient Test...

      Mar 21, 2018 9:36:21 AM org.wildfly.naming.client.Version <clinit>

      INFO: WildFly Naming version 1.0.7.Final

      Mar 21, 2018 9:36:21 AM org.wildfly.security.Version <clinit>

      INFO: ELY00001: WildFly Elytron version 1.1.6.Final

      Mar 21, 2018 9:36:21 AM org.xnio.Xnio <clinit>

      INFO: XNIO version 3.5.4.Final

      Mar 21, 2018 9:36:21 AM org.xnio.nio.NioXnio <clinit>

      INFO: XNIO NIO Implementation Version 3.5.4.Final

      Mar 21, 2018 9:36:21 AM org.jboss.remoting3.EndpointImpl <clinit>

      INFO: JBoss Remoting version 5.0.5.Final

      Exception in thread "main" java.lang.NullPointerException

        at org.wildfly.naming.client.remote.ProtocolUtils.createUnmarshaller(ProtocolUtils.java:66)

        at org.wildfly.naming.client.remote.RemoteClientTransport.lookup(RemoteClientTransport.java:246)

        at org.wildfly.naming.client.remote.RemoteContext.lambda$lookupNative$0(RemoteContext.java:190)

        at org.wildfly.naming.client.NamingProvider.performExceptionAction(NamingProvider.java:222)

        at org.wildfly.naming.client.remote.RemoteContext.performWithRetry(RemoteContext.java:100)

        at org.wildfly.naming.client.remote.RemoteContext.lookupNative(RemoteContext.java:188)

        at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:74)

        at org.wildfly.naming.client.AbstractFederatingContext.lookup(AbstractFederatingContext.java:60)

        at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:144)

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

        at ExternalClient.main(ExternalClient.java:30)

       

       

       

      The user xxx:yyyy is registered as an "Application User" using $JBOSS_HOME/bin/add-user.sh

       

      and my classpath is:

      $JBOSS_HOME/modules/system/layers/base/org/jboss/ejb-client/main/jboss-ejb-client-4.0.7.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/jboss/marshalling/main/jboss-marshalling-2.0.2.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/jboss/xnio/nio/main/xnio-nio-3.5.4.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/wildfly/client/config/main/wildfly-client-config-1.0.0.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/jboss/remoting/main/jboss-remoting-5.0.5.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/jboss/xnio/main/xnio-api-3.5.4.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/wildfly/common/main/wildfly-common-1.2.0.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/wildfly/security/elytron-private/main/wildfly-elytron-1.1.6.Final.jar:

      $JBOSS_HOME/modules/system/layers/base/org/wildfly/naming-client/main/wildfly-naming-client-1.0.7.Final.jar

      $JBOSS_HOME/modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.3.1.Final.jar:

       

       

      Any idea, what I'm missing here?