Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-20822

(7.3.z) WEJBHTTP-51 - Http Naming Client does not get root cause of failure of remote bind operation

XMLWordPrintable

      The Remote Naming (JNDI) is Read-Only, remote clients cannot bind or rebind objects into it. Only applications running in the same JVM can bind values into JNDI.

        public static void main(String[] args) throws Exception {
          Context ctx = getInitialContext("localhost", 8080, "admin", "redhat1!");
            ctx.bind("java:/reproducer", "reproducer");
            ctx.rebind("java:/reproducer", "reproducer");
        }
      
      
      public static Context getInitialContext(String host, Integer port, String username, String password)  throws NamingException {
         Properties props = new Properties();
         props.put(Context.INITIAL_CONTEXT_FACTORY,  "org.wildfly.naming.client.WildFlyInitialContextFactory");
         props.put(Context.PROVIDER_URL, String.format("%s://%s:%d/wildfly-services", "http", host, port));
         if(username != null && password != null) {
            props.put(Context.SECURITY_PRINCIPAL, username);
            props.put(Context.SECURITY_CREDENTIALS, password);
          }
         return new InitialContext(props);
      }
      
      

      then you do get a NamingException on client side:

      Exception in thread "main" javax.naming.NamingException [Root exception is java.io.IOException: WFHTTP000005: Invalid response code 500 (full response ClientResponse{responseHeaders={content-type=[text/html], content-length=[2480], date=[Tue, 12 May 2020 20:55:10 GMT]}, responseCode=500, status='', protocol=HTTP/2.0})]
      	at org.wildfly.httpclient.naming.HttpRootContext.performOperation(HttpRootContext.java:442)
      	at org.wildfly.httpclient.naming.HttpRootContext.lambda$processInvocation$4(HttpRootContext.java:383)
      	at org.wildfly.httpclient.naming.HttpRootContext.performWithRetry(HttpRootContext.java:182)
      	at org.wildfly.httpclient.naming.HttpRootContext.processInvocation(HttpRootContext.java:364)
      	at org.wildfly.httpclient.naming.HttpRootContext.rebindNative(HttpRootContext.java:146)
      	at org.wildfly.naming.client.AbstractContext.rebind(AbstractContext.java:154)
      	at org.wildfly.naming.client.AbstractContext.rebind(AbstractContext.java:152)
      	at org.wildfly.naming.client.WildFlyRootContext.rebind(WildFlyRootContext.java:195)
      	at java.naming/javax.naming.InitialContext.rebind(InitialContext.java:425)
      	at org.example.Test.main(Test.java:47)
      Caused by: java.io.IOException: WFHTTP000005: Invalid response code 500 (full response ClientResponse{responseHeaders={content-type=[text/html], content-length=[2480], date=[Tue, 12 May 2020 20:55:10 GMT]}, responseCode=500, status='', protocol=HTTP/2.0})
      	at org.wildfly.httpclient.common.HttpTargetContext$1$1.lambda$completed$4(HttpTargetContext.java:234)
      	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      

      The root cause of the exception should be something like:

      Caused by: javax.naming.OperationNotSupportedException: WFLYNAM0043: Naming context is read-only
              at org.jboss.as.naming.WritableServiceBasedNamingStore.requireOwner(WritableServiceBasedNamingStore.java:163)
              at org.jboss.as.naming.WritableServiceBasedNamingStore.bind(WritableServiceBasedNamingStore.java:69)
              at org.jboss.as.naming.NamingContext.bind(NamingContext.java:262)
              at org.jboss.as.naming.NamingContext.bind(NamingContext.java:289)
              at org.wildfly.httpclient.naming.HttpRemoteNamingService$BindHandler.doOperation(HttpRemoteNamingService.java:237)
              at org.wildfly.httpclient.naming.HttpRemoteNamingService$BindHandler.doOperation(HttpRemoteNamingService.java:227)
      

      The same issue for rebind / rename / createSubContext / destroySubContext etc.

              rhn-engineering-lgao Lin Gao
              rhn-engineering-lgao Lin Gao
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: