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

    Discover JNDI names inside  EAR [wildfly 11]

    ainsel

      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)

      .....

        • 1. Re: Discover JNDI names inside  EAR [wildfly 11]
          dmlloyd

          You should also give the contents of your jndiProperties, and also more of the stack trace: the first and last loop as well as the base of the stack up to the loop would be useful.

          • 2. Re: Discover JNDI names inside  EAR [wildfly 11]
            ainsel

            JndiProperties added, it just from the standard example so nothing fancy. 

            As the error trace goes these 4 errors appear until in loop until stack overflows

            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)

            • 3. Re: Discover JNDI names inside  EAR [wildfly 11]
              andey

              The amount of stack space required by the program exceeds (than JVM allocated size) for the following reasons:

              - The program and/or use-case requires a larger stack (e.g., graphics-intensive programs).

              - The application is deeply-nested (recursion).

              - Infinite loops

               

              If a StackOverflow occurs when trying to serialize a deep object graph, the stacktrace logged can exhaust the server's disk space.

               

              Increase the thread stack size by increments of 64k until the StackOverflowError disappears.

              Alternative, modify the code or configuration(s) to avoid recursion or infinite loops.

              • 4. Re: Discover JNDI names inside  EAR [wildfly 11]
                ainsel

                The problem lies  strictly in wrong execution of :

                   context.list("ear_name/jar_name") ;

                 

                When trying to list beans registered under java:global/ear_name/jar_name  JNDI.   Trace suggest that the  error lead to infinite loop inside wildfly.client so increasing stack won't do anything really. 

                 

                If this may be a configuration problem I'm  open for any advice what I can change to make it work.

                 

                 

                 

                 

                • 5. Re: Discover JNDI names inside  EAR [wildfly 11]
                  dmlloyd

                  I have a possible fix for this issue in: [WFNC-xxx] Decompose all absolute names to avoid infinite recursion (… · dmlloyd/wildfly-naming-client@f70f849 · GitHub

                   

                  I'll open a JIRA for this; in the meantime, if you are able to test the change and post your results, I'd appreciate it.