5 Replies Latest reply on May 24, 2018 10:19 AM by David Lloyd

    Discover JNDI names inside  EAR [wildfly 11]

    Sliff Ainsel Newbie

      Hello,

       

      I am making a client to automatically discover available JNDI names on server, and the i have problem with beans that are packed inside ear.  The beans deployed directly shows fine, but when I try list beans's inside ear code throw java.lang.StackOverflowError.

      Server expose 4 JNDI Paths:

      java:global/bean-jar-0.0.1-SNAPSHOT/Counter!org.beanjar.stateful.CounterRemote

      java:global/bean-jar-0.0.1-SNAPSHOT/Calculator!org.beanjar.stateless.CalculatorRemote

      java:global/any_name/bean-jar/Counter!org.beanjar.stateful.CounterRemote

      java:global/any_name/bean-jar/Calculator!org.beanjar.stateless.CalculatorRemote

      Client test code:

       final Hashtable<string, string=""> jndiProperties = new Hashtable<>();
              // jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
              jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
              jndiProperties.put(Context.PROVIDER_URL, "remote+http://localhost:8080");
              final Context context = new InitialContext(jndiProperties);
       final Context context = new InitialContext(jndiProperties);
      
      NamingEnumeration ctxlst =   context.list("");
              while (ctxlst.hasMore()) {
                  NameClassPair ncp = (NameClassPair)ctxlst.next();
                  System.out.println( ncp.getClassName() + ": " + ncp.isRelative() +":" + ncp.getName());        }
      
              NamingEnumeration ctxlst1 =   context.list("bean-jar-0.0.1-SNAPSHOT");
              while (ctxlst1.hasMore()) {
                  NameClassPair ncp = (NameClassPair)ctxlst1.next();
                  System.out.println( ncp.getClassName() + ": " + ncp.isRelative() +":" + ncp.getName());        }
      
              NamingEnumeration ctxlst2 =   context.list("any_name");
              while (ctxlst2.hasMore()) {
                  NameClassPair ncp = (NameClassPair)ctxlst2.next();
                  System.out.println( ncp.getClassName() + ": " + ncp.isRelative() +":" + ncp.getName());        }
      
              NamingEnumeration ctxlst3 =   context.list("any_name/bean-jar") ;
              while (ctxlst3.hasMore()) {
                  NameClassPair ncp = (NameClassPair)ctxlst3.next();
                  System.out.println( ncp.getClassName() + ": " + ncp.isRelative() +":" + ncp.getName());        }

      Output:

      javax.naming.Context: true:bean-jar-0.0.1-SNAPSHOT

      javax.naming.Context: true:any_name

       

      java.lang.Object: true:Calculator!org.beanjar.stateless.CalculatorRemote

      java.lang.Object: true:Counter!org.beanjar.stateful.CounterRemote

       

      javax.naming.Context: true:bean-jar

       

      Exception in thread "main" java.lang.StackOverflowError

      at java.lang.StringBuffer.append(StringBuffer.java:270)

      at java.net.URI.appendAuthority(URI.java:1835)

      at java.net.URI.appendSchemeSpecificPart(URI.java:1909)

      at java.net.URI.toString(URI.java:1941)

      at java.net.URI.<init>(URI.java:669)

      at org.jboss.remoting3.EndpointImpl.doGetConnection(EndpointImpl.java:466)

      at org.jboss.remoting3.EndpointImpl.getConnectedIdentity(EndpointImpl.java:433)

      at org.jboss.remoting3.UncloseableEndpoint.getConnectedIdentity(UncloseableEndpoint.java:51)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.getFuturePeerIdentityPrivileged(RemoteNamingProvider.java:151)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.lambda$getFuturePeerIdentity$0(RemoteNamingProvider.java:138)

      at java.security.AccessController.doPrivileged(Native Method)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.getFuturePeerIdentity(RemoteNamingProvider.java:138)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.getPeerIdentity(RemoteNamingProvider.java:126)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.getPeerIdentityForNaming(RemoteNamingProvider.java:106)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.getPeerIdentityForNaming(RemoteNamingProvider.java:53)

      at org.wildfly.naming.client.NamingProvider.getPeerIdentityForNamingUsingRetry(NamingProvider.java:105)

      at org.wildfly.naming.client.remote.RemoteNamingProvider.getPeerIdentityForNamingUsingRetry(RemoteNamingProvider.java:91)

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

      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.list(AbstractFederatingContext.java:276)

      at org.wildfly.naming.client.store.RelativeFederatingContext.listNative(RelativeFederatingContext.java:78)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:274)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:42)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:280)

      at org.wildfly.naming.client.store.RelativeFederatingContext.listNative(RelativeFederatingContext.java:78)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:274)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:42)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:280)

      at org.wildfly.naming.client.store.RelativeFederatingContext.listNative(RelativeFederatingContext.java:78)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:274)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:42)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:280)

      at org.wildfly.naming.client.store.RelativeFederatingContext.listNative(RelativeFederatingContext.java:78)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:274)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:42)

      at org.wildfly.naming.client.AbstractFederatingContext.list(AbstractFederatingContext.java:280)

      .....